Skip to content Skip to sidebar Skip to footer

Error Encode/decode Base64 Between Java And Android

I have a problem when I encode/decode Base64 between Java and Android. Here is my case: I write code to encrypt/decrypt using ECC on Java, my code work very well. Then I try to enc

Solution 1:

This seems to be a simple mistake. You replaced

Stringabc= Base64.getDecoder().decode(encrypt);

with

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

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

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

Post a Comment for "Error Encode/decode Base64 Between Java And Android"