8
回答
初学者问一行JAVA代码的含义
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
    {
            String str2 = com.jd.b.a.a.a(locala.a( str1)).toUpperCase();//这行代码的含义?两次调用构造函数?
      return str2;
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
    }
    return "";
  }



下面的是引用包的源码

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();
    }
  }
}






<无标签>
举报
莫某菜鸟
发帖于4年前 8回/555阅
顶部