我有一个简单的代码来加密和解密字符串。这种加密和解密大部分时间起作用,除非我试图解密这个值,
zxF9LGKNLzPQgkE5/SUbCbCp7SlWFTafGWdfbIylRhwfwMLBLoh/VDYOyg/vK4b+我得到了这个错误,
java.lang.IllegalArgumentException: Illegal base64 character 20此加密值是使用以下字符串UUID生成的,
32787d1b-abee 49de-af3e-b51f53dd2b96
下面是我用来加密的代码,
try
{
cipher.init(Cipher.ENCRYPT_MODE, key);
final String encodedString = Base64.getEncoder().encodeToString(cipher.doFinal(rawString.getBytes(chaEncoding)));
return new String(encodedString.getBytes(chaEncoding));
}
catch (InvalidKeyException | IllegalBlockSizeException | BadPaddingException e)
{
throw e;
}这是我用来解密的代码,
try
{
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] plainText = cipher.doFinal(Base64.getDecoder().decode(encryptedString.getBytes(chaEncoding)));
return new String(plainText, chaEncoding);
}
catch (InvalidKeyException | IllegalBlockSizeException | BadPaddingException e)
{
throw e;
}发布于 2018-06-22 17:27:44
问题出现在"+“号上。我将其部署为spring引导应用程序,所以+在URL中的意思是“空间”。我更改了代码以从请求体获得加密字符串。谢谢大家。
https://stackoverflow.com/questions/50992539
复制相似问题