This is the Base64 class :
http://iharder.sourceforge.net/current/java/base64/
the problem is, i have two Editext
and one Button
in my activity.so i need to use this for encode the string from Edittext1
with the one Button and then it show us the result(encoded result) on EditText2
.
how we can do this and use this class for encode the strings?
i read the details about this class and i cannot figure out how can i use this for encode (input - output string in android)
How we can do this ?
Cheers!.
Don't use a third-party class in this case - Android already has a Base64
class.
Just use Base64.encodeToString(byte[], int)
and Base64.decode(String, int)
.
Note that base64-encoding is for binary data, so if your actual source is text, you'll need to work out an encoding to use first... e.g. UTF-8. For example:
String sourceText = ...;
byte[] sourceBinary = sourceText.getByte(StandardCharsets.UTF_8);
String base64 = Base64.encode(sourceBinary, Base64.DEFAULT);
See more on this question at Stackoverflow