部分关键代码如下,aes加解密在windows系统上是好的,但部署到linux服务器上,执行到这一行的时候,报错了,执行不下去了,请教哪位高手遇到过,赐教,不甚感激!
byte[] original = cipher.doFinal(encrypted1);//*********************************************************************************************/
// 解密
public static String Decrypt(String sSrc, String sKey) throws Exception {
try {
// 判断Key是否正确
if (sKey == null) {
System.out.print("Key为空null");
return null;
}
// 判断Key是否为16位
if (sKey.length() != 16) {
System.out.print("Key长度不是16位");
return null;
}
byte[] raw = sKey.getBytes("ASCII");
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
IvParameterSpec iv = new IvParameterSpec("0102030405060708"
.getBytes());
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
byte[] encrypted1 = new BASE64Decoder().decodeBuffer(sSrc);//先用base64解密
try {
byte[] original = cipher.doFinal(encrypted1);
String originalString = new String(original);
return originalString;
} catch (Exception e) {
System.out.println(e.toString());
return null;
}
} catch (Exception ex) {
System.out.println(ex.toString());
return null;
}
}
byte[] original = cipher.doFinal(encrypted1);//*********************************************************************************************/
// 解密
public static String Decrypt(String sSrc, String sKey) throws Exception {
try {
// 判断Key是否正确
if (sKey == null) {
System.out.print("Key为空null");
return null;
}
// 判断Key是否为16位
if (sKey.length() != 16) {
System.out.print("Key长度不是16位");
return null;
}
byte[] raw = sKey.getBytes("ASCII");
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
IvParameterSpec iv = new IvParameterSpec("0102030405060708"
.getBytes());
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
byte[] encrypted1 = new BASE64Decoder().decodeBuffer(sSrc);//先用base64解密
try {
byte[] original = cipher.doFinal(encrypted1);
String originalString = new String(original);
return originalString;
} catch (Exception e) {
System.out.println(e.toString());
return null;
}
} catch (Exception ex) {
System.out.println(ex.toString());
return null;
}
}
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!
帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!
帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!帮你顶顶!
顶!顶!顶!顶!顶!