From d3fefc811b21d07cf8cb8606354b75e6865d8fd9 Mon Sep 17 00:00:00 2001 From: baohanddd Date: Wed, 14 Sep 2016 16:12:17 +0800 Subject: [PATCH] add mongo sync --- .../main/java/com/lyms/platform/common/utils/LymsEncodeUtil.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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")); -- 1.8.3.1