Hi,
I am using these two methods to make a Base64-encoded String from a regular text. First convert it to a byte[] and then to Base64 encoding.
My problem is, later on I need to use the original text again. Can anybody help me on how I get back from the Base64-encoded text "YWJjMTIz" to "abc123"?
I am using these two methods to make a Base64-encoded String from a regular text. First convert it to a byte[] and then to Base64 encoding.
Code:
String originalText = "abc123";
String base64Text = toBase64(originalText);
private String toBase64(String s) throws SystemException {
return new BASE64Encoder().encode(toByteArray(s));
}
private byte[] toByteArray(String s) throws SystemException {
try {
return s.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
SystemException se = new SystemException();
throw se;
}
}
My problem is, later on I need to use the original text again. Can anybody help me on how I get back from the Base64-encoded text "YWJjMTIz" to "abc123"?