org.mitre.jsip.util
Class Base64

java.lang.Object
  |
  +--org.mitre.jsip.util.Base64

public class Base64
extends java.lang.Object


Constructor Summary
Base64()
           
 
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

Base64

public Base64()
Method Detail

decode

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.


encode

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