(improvement)(headless) Opt encrypt database password, avoid repeated decryption.(#1326) (#1562)

Co-authored-by: lxwcodemonkey
This commit is contained in:
LXW
2024-08-13 10:10:52 +08:00
committed by GitHub
parent d32d791238
commit 95be7f3ce1
6 changed files with 19 additions and 37 deletions

View File

@@ -90,12 +90,16 @@ public class AESEncryptionUtil {
return Base64.getEncoder().encodeToString(combined);
}
public static String aesEncryptECB(String content) throws Exception {
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
SecretKeySpec secretKeySpec = new SecretKeySpec(hexStringToByteArray(KEY), "AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
byte[] encryptEncode = cipher.doFinal(content.getBytes(ENCODE));
return getStringFromBytes(encryptEncode);
public static String aesEncryptECB(String content) {
try {
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
SecretKeySpec secretKeySpec = new SecretKeySpec(hexStringToByteArray(KEY), "AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
byte[] encryptEncode = cipher.doFinal(content.getBytes(ENCODE));
return getStringFromBytes(encryptEncode);
} catch (Exception e) {
return content;
}
}
public static String aesDecryptECB(String encryptStr) {