AES加密/解密报错,Input length must be multiple of 16 when decrypting with padded cipher
程序员文章站
2022-07-10 15:25:26
...
背景:需要存储一个类似**的字符串,密文存储,并要求能逆向解密出来。
问题描述:使用AES对该字符串进行加密后生成byte数组,使用new String()方法转为字符串后存储到数据库。
从数据库中取出密文,使用getBytes()方法转换为byte数组,然后解密,此时报如下错误:
javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:922)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:833)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446)
at javax.crypto.Cipher.doFinal(Cipher.java:2165)
解决思路:AES加密-->base64编码->密文
密文-->base64解码->AES解密
上一篇: Python 下smtplib模块
下一篇: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with pad
推荐阅读
-
Des加密解密算法报错:Input length must be multiple of 8 when decrypting with padded cipher
-
AES加密/解密报错,Input length must be multiple of 16 when decrypting with padded cipher
-
Input length must be multiple of 8 when decrypting with padded cipher 错误
-
java对称加密报错:Input length must be multiple of 8 when decrypting with padded cipher
-
java AES 加密,报javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decryp
-
JAVA实现AES 解密报错Input length must be multiple of 16 when decrypting with padded cipher