Class Base64


public class Base64
extends java.lang.Object

Constructor Summary
Method Summary
static java.lang.String decode(java.lang.String encoded)
          decode a Base 64 encoded String.
static java.lang.String encode(java.lang.String plain)
          encode plaintext data to a base 64 string
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public Base64()
Method Detail


public static java.lang.String decode(java.lang.String encoded)
decode a Base 64 encoded String.

String to byte conversion

This method uses a naive String to byte interpretation, it simply gets each char of the String and calls it a byte.

Since we should be dealing with Base64 encoded Strings that is a reasonable assumption.

End of data

We don't try to stop the converion when we find the "=" end of data padding char. We simply add zero bytes to the unencode buffer.


public static java.lang.String encode(java.lang.String plain)
encode plaintext data to a base 64 string
plain - the text to convert. If plain is longer than 76 characters this method returns null (see RFC2045).
the encoded text (or null if string was longer than 76 chars).