📄 test.java
字号:
e.printStackTrace();
}
}
public String dec(String key ,byte[] aess) {
System.out.println("======================================================");
byte[] raw =key.getBytes();
Cipher cipher =null;
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
try {
cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
try {
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
} catch (InvalidKeyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchPaddingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// byte[] encrypted1 = hex2byte(sSrc);
String doc = "";
//byte[] bytOuta = cipher.doFinal(aess);
System.out.println(aess.length);
byte[] bytOut;
bytOut = cipher.update(aess);
doc = new String (bytOut);
return doc;
}
public static byte[] hex2byte(String strhex) {
if (strhex == null) {
return null;
}
int l = strhex.length();
if (l % 2 == 1) {
return null;
}
byte[] b = new byte[l / 2];
for (int i = 0; i != l / 2; i++) {
b[i] = (byte) Integer.parseInt(strhex.substring(i * 2, i * 2 + 2), 32);
}
return b;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -