[Java] 纯文本查看 复制代码 private static byte[] m2867a(String str) {
byte[] bArr = new byte[(str.length() / 2)];
int length = str.length();
for (int i = 0; i < length; i += 2) {
bArr[i / 2] = (byte) Integer.parseInt(str.substring(i, i + 2), 16);
}
return bArr;
}
public static byte[] m2868a(byte[] bArr, String str) {
if (bArr.length == 16) { // short key ? .. extend to 24 byte key
byte[] tmpKey = new byte[24];
System.arraycopy(bArr, 0, tmpKey, 0, 16);
System.arraycopy(bArr, 0, tmpKey, 16, 8);
bArr = tmpKey;
}
SecretKeySpec secretKeySpec = new SecretKeySpec(bArr, "DESede");
Cipher instance = Cipher.getInstance("DESede/ECB/NoPadding");
instance.init(2, secretKeySpec);
return instance.doFinal(m2867a(str));
}
小弟实在感激不尽,对Java不太熟,看不太懂 |