且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java和Android之间的Base64错误编码/解码

更新时间:2023-02-11 12:07:39

这似乎是一个简单的错误. 您替换了

This seems to be a simple mistake. You replaced

String abc = Base64.getDecoder().decode(encrypt);

使用

byte[] encodeBytes = null;
encodeBytes = Base64.encode(my_encrypted_string.getBytes(),Base64.DEFAULT);

如果我没看错的话.尝试用 decode .

if I read this correctly. Try to replace that with decode instead.

由于密文是对Base64进行两次编码而不是在尝试对其进行解密之前进行解码的,因此解密失败并显示您向我们显示的错误.

As the ciphertext is Base64 encoded twice instead of decoded before attempting to decrypt it, decryption fails with the error you showed us.