Commit d3fefc811b21d07cf8cb8606354b75e6865d8fd9

Authored by baohanddd
1 parent 17809fd805

add mongo sync

Showing 1 changed file with 6 additions and 2 deletions

platform-common/src/main/java/com/lyms/platform/common/utils/LymsEncodeUtil.java View file @ d3fefc8
... ... @@ -101,7 +101,9 @@
101 101 */
102 102 public static byte[] aesEncryptToBytes(String content, String encryptKey) throws Exception {
103 103 KeyGenerator kgen = KeyGenerator.getInstance("AES");
104   - kgen.init(128, new SecureRandom(encryptKey.getBytes()));
  104 + SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
  105 + random.setSeed(encryptKey.getBytes());
  106 + kgen.init(128, random);
105 107  
106 108 Cipher cipher = Cipher.getInstance("AES");
107 109 cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(kgen.generateKey().getEncoded(), "AES"));
... ... @@ -129,7 +131,9 @@
129 131 */
130 132 public static String aesDecryptByBytes(byte[] encryptBytes, String decryptKey) throws Exception {
131 133 KeyGenerator kgen = KeyGenerator.getInstance("AES");
132   - kgen.init(128, new SecureRandom(decryptKey.getBytes()));
  134 + SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
  135 + random.setSeed(decryptKey.getBytes());
  136 + kgen.init(128, random);
133 137  
134 138 Cipher cipher = Cipher.getInstance("AES");
135 139 cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(kgen.generateKey().getEncoded(), "AES"));