Java AES decryption BadPaddingException

十年热恋 提交于 2019-12-03 20:47:34

Use the function encodeBase64URLSafeString. the javadoc says

Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The url-safe variation emits - and _ instead of + and / characters. Note: no padding is added.

This should solve the problem.

Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc).

Your conversion to/from byte[]/string does not preserve all the data. Textual representation of the ciphertext isn't really necessary so why are you converting to a string?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!