Possible Duplicate:
Base64 encoder and decoder
I am trying to encode a Url with Base64. Is there any way to encode it with Base64 in java/android?
I need something similar to base64_encode() function in PHP.
(Theoretical answer.) Double-base-64-encoded strings are regular, because there is a finite amount of byte sequences that properly base64-encode a base64-encoded message. You can check if something is base64-encoded once since you can validate each set of four characters.
If we were to Base64 encode a string we would follow these steps: Take the ASCII value of each character in the string. Calculate the 8-bit binary equivalent of the ASCII values. Convert the 8-bit chunks into chunks of 6 bits by simply re-grouping the digits.
When decoding Base64 text, four characters are typically converted back to three bytes. The only exceptions are when padding characters exist. A single = indicates that the four characters will decode to only two bytes, while == indicates that the four characters will decode to only a single byte.
Base64 is not Encryption While it may obfuscate that actual data from should surfers, anyone who has access to base64 encoded data can easily decode it.
Base64 is part of the Android SDK from API level 8 onwards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With