|
|
|
@ -13,7 +13,6 @@ public class AesEncryptUtil {
|
|
|
|
|
|
|
|
|
|
//使用AES-128-CBC加密模式,key需要为16位,key和iv可以相同!
|
|
|
|
|
private static String KEY = EncryptedString.key;
|
|
|
|
|
|
|
|
|
|
private static String IV = EncryptedString.iv;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -45,7 +44,7 @@ public class AesEncryptUtil {
|
|
|
|
|
cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
|
|
|
|
|
byte[] encrypted = cipher.doFinal(plaintext);
|
|
|
|
|
|
|
|
|
|
return new Base64().encodeToString(encrypted);
|
|
|
|
|
return Base64.encodeToString(encrypted);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
@ -63,7 +62,7 @@ public class AesEncryptUtil {
|
|
|
|
|
*/
|
|
|
|
|
public static String desEncrypt(String data, String key, String iv) throws Exception {
|
|
|
|
|
try {
|
|
|
|
|
byte[] encrypted1 = new Base64().decode(data);
|
|
|
|
|
byte[] encrypted1 = Base64.decode(data);
|
|
|
|
|
|
|
|
|
|
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
|
|
|
|
|
SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");
|
|
|
|
|