Skip to content

Commit

Permalink
KYLIN-4478 Resolve Issue: Use secure AES/CFB/PKCS5Padding instead of …
Browse files Browse the repository at this point in the history
…insecure AES/ECB/PKCS5Padding

Signed-off-by: shaofengshi <shaofengshi@apache.org>
(cherry picked from commit dadc1dd)
  • Loading branch information
mahirkabir authored and hit-lacus committed Jun 27, 2021
1 parent b99ac75 commit 277202a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static String encrypt(String strToEncrypt) {
return null;
}
try {
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
Cipher cipher = Cipher.getInstance("AES/CFB/PKCS5Padding");
final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
final String encryptedString = Base64.encodeBase64String(cipher.doFinal(strToEncrypt.getBytes(
Expand All @@ -52,7 +52,7 @@ public static String decrypt(String strToDecrypt) {
return null;
}
try {
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
Cipher cipher = Cipher.getInstance("AES/CFB/PKCS5Padding");
final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
cipher.init(Cipher.DECRYPT_MODE, secretKey);
final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt)), StandardCharsets.UTF_8);
Expand Down

0 comments on commit 277202a

Please sign in to comment.