Hi all,
i got the the part of source code from https://www.devglan.com/online-tools/aes-encryption-decryption , any ideas to adapt this to Autoit ?
@RequestMapping(value = "/aes-decryption", method=RequestMethod.POST)
public @ResponseBody String aesDecrypt(@RequestBody AesEncryption aesEncryption) {
if(aesEncryption.getKeySize() > 128) {
try {
Field field = Class.forName("javax.crypto.JceSecurity").
getDeclaredField("isRestricted");
field.setAccessible(true);
field.set(null, false);
} catch (Exception ex) {
ex.printStackTrace();
}
}
String output;
try{
SecretKeySpec skeySpec = new SecretKeySpec(aesEncryption.getSecretKey().getBytes("UTF-8"), "AES");
Cipher cipher = Cipher.getInstance("AES/"+aesEncryption.getMode()+"/PKCS5PADDING");
if(aesEncryption.getMode().equals("ECB")){
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
}else {
IvParameterSpec iv = StringUtils.isEmpty(aesEncryption.getIv()) ? new IvParameterSpec(new byte[16]): new IvParameterSpec(aesEncryption.getIv().getBytes("UTF-8"));
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
}
byte[] original;
if(aesEncryption.getDataFormat().equals("Base64")) {
original = cipher.doFinal(Base64.decodeBase64(aesEncryption.getTextToDecrypt()));
}else {
original = cipher.doFinal(DatatypeConverter.parseHexBinary(aesEncryption.getTextToDecrypt()));
}
output = Base64.encodeBase64String(original);
} catch (Exception ex) {
output = ex.getMessage();
}
return output;
}
Thanks
Marcus