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();
}
}
}
------解决思路----------------------
Calendar localCalendar = Calendar.getInstance(Locale.CHINESE); Calendar 提供了一个类方法 getInstance,以获得此类型的一个通用的对象。Calendar 的 getInstance 方法返回一个 Calendar 对象 Locale.CHINESE 中国地区
StringBuilder localStringBuilder = new StringBuilder();
StringBuffer 字符串变量(线程安全)
StringBuilder 字符串变量(非线程安全)
Object[] arrayOfObject = new Object[1]; //声明object对象数组
arrayOfObject[0] = Integer.valueOf(localCalendar.get(6));// 取当前时间
String str2 = com.jd.b.a.a.a(locala.a(String.format("%03d", arrayOfObject) + str1)).toUpperCase();//格式化为至少3位十进制整数在toUpperCase转换大写
return str2 //返回字符串
------解决思路----------------------
日期计算的api哈..