public byte[] AesEncrypt(String str) throws Exception
{
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, "0123456789ABCDEF");
return cipher.doFinal(str.getBytes());
}
public static String EncryptAES (String str) throws Exception
{
var bytes = str.getBytes(StandardCharsets.UTF_8);
var key = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
var iv = "bbbbbbbbbbbbbbbb";
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES");
Cipher instance = Cipher.getInstance("AES/CBC/PKCS5Padding");
instance.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(iv.getBytes(StandardCharsets.UTF_8)));
var encryptedBytes = instance.doFinal(bytes);
return Base64.getEncoder().encodeToString(encryptedBytes);
}