Class Base64


public class Base64
extends java.lang.Object

Basically, the problem is that sometimes you want to store binary objects where you only have text storage facilities. This converts an array of bytes to and from printable only characters so you can store any set of bytes where only text storage is availabe.

This code comes from the book _Java Crypotgraphy_ by Jonathan Knudsen published by O'Reilly. It's inclusion in IGLU is in accordance with O'Reilly's fair use policy as noted at: http://www.oreilly.com/ask_tim/codepolicy_1101.html.

Constructor Summary
Method Summary
static byte[] decode(java.lang.String base64)
          Decode the string to its equivalent non-printable byte array
static java.lang.String encode(byte[] raw)
          encode the given byte array as a printable string
protected static char[] encodeBlock(byte[] raw, int offset)
          Encode the indicated block
protected static char getChar(int sixBit)
protected static int getValue(char c)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public Base64()
Method Detail


public static java.lang.String encode(byte[] raw)
encode the given byte array as a printable string


protected static char[] encodeBlock(byte[] raw,
                                    int offset)
Encode the indicated block


protected static char getChar(int sixBit)


public static byte[] decode(java.lang.String base64)
Decode the string to its equivalent non-printable byte array


protected static int getValue(char c)