初学者问几行JAVA代码的含义

莫某菜鸟 发布于 2014/11/06 13:28
阅读 828
收藏 0
private static String a(String paramString1, String paramString2, String paramString3)
  {
    String str1 = "username=" + paramString1 + ",pwd=" + paramString2 + ",uuid=" + paramString3;
    com.jd.b.a.a locala = new com.jd.b.a.a();
    try
    {
      Calendar localCalendar = Calendar.getInstance(Locale.CHINESE);
      StringBuilder localStringBuilder = new StringBuilder();
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = Integer.valueOf(localCalendar.get(6));
      String str2 = com.jd.b.a.a.a(locala.a(String.format("%03d", arrayOfObject) + str1)).toUpperCase();
      return str2;
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
    }
    return "";
  }

上面try里面的几行代码的含义


下面是引用包的代码

package com.jd.b.a;

import java.security.NoSuchProviderException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;

public final class a
{
  IvParameterSpec a = new IvParameterSpec(this.b);
  private final byte[] b = "3#6q0/bj".getBytes();
  private SecretKey c;
  private Cipher d;

  public a()
  {
    try
    {
      DESKeySpec localDESKeySpec = new DESKeySpec("3#6q0/bj".getBytes());
      this.c = SecretKeyFactory.getInstance("DES").generateSecret(localDESKeySpec);
      this.d = Cipher.getInstance("DES/CBC/PKCS5Padding");
      this.d.init(1, this.c, this.a);
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      return;
    }
    catch (NoSuchProviderException localNoSuchProviderException)
    {
      localNoSuchProviderException.printStackTrace();
    }
  }

  public static String a(byte[] paramArrayOfByte)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < paramArrayOfByte.length; i++)
    {
      String str = Integer.toHexString(0xFF & paramArrayOfByte[i]);
      if (str.length() < 2)
        str = "0" + str;
      localStringBuffer.append(str);
    }
    return localStringBuffer.toString();
  }

  public final byte[] a(String paramString)
  {
    try
    {
      byte[] arrayOfByte = this.d.doFinal(paramString.getBytes());
      return arrayOfByte;
    }
    catch (BadPaddingException localBadPaddingException)
    {
      localBadPaddingException.printStackTrace();
      return null;
    }
    catch (IllegalBlockSizeException localIllegalBlockSizeException)
    {
      while (true)
        localIllegalBlockSizeException.printStackTrace();
    }
  }
}






加载中
0
莱特钉
莱特钉

对数据进行des加密

上面试组明文

下面是加密算法

返回顶部
顶部