diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/LymsEncodeUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/LymsEncodeUtil.java index 0caf661..7cae6d6 100644 --- a/platform-common/src/main/java/com/lyms/platform/common/utils/LymsEncodeUtil.java +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/LymsEncodeUtil.java @@ -101,7 +101,9 @@ public class LymsEncodeUtil { */ public static byte[] aesEncryptToBytes(String content, String encryptKey) throws Exception { KeyGenerator kgen = KeyGenerator.getInstance("AES"); - kgen.init(128, new SecureRandom(encryptKey.getBytes())); + SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); + random.setSeed(encryptKey.getBytes()); + kgen.init(128, random); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(kgen.generateKey().getEncoded(), "AES")); @@ -129,7 +131,9 @@ public class LymsEncodeUtil { */ public static String aesDecryptByBytes(byte[] encryptBytes, String decryptKey) throws Exception { KeyGenerator kgen = KeyGenerator.getInstance("AES"); - kgen.init(128, new SecureRandom(decryptKey.getBytes())); + SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); + random.setSeed(decryptKey.getBytes()); + kgen.init(128, random); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(kgen.generateKey().getEncoded(), "AES"));