Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to encode a string with Base64 in Android? [duplicate]

Tags:

java

android

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.

like image 689
Kalimah Avatar asked Oct 07 '11 13:10

Kalimah


People also ask

Can you Base64 encode twice?

(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.

How do I Base64 encode a string?

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.

What does == mean in Base64?

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.

Can you crack Base64?

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.


1 Answers

Base64 is part of the Android SDK from API level 8 onwards.

like image 67
Graham Borland Avatar answered Sep 20 '22 05:09

Graham Borland