it.unimo.dbgroup.momis.tools
Class Base64

java.lang.Object
  extended byit.unimo.dbgroup.momis.tools.Base64

public class Base64
extends java.lang.Object

Provides encoding of raw bytes to base64-encoded characters, and decoding of base64 characters to raw bytes.

Version:
1.2
Author:
Kevin Kelley (kelley@ruralnet.net)

Field Summary
private static char[] alphabet
          code characters for values 0..63
private static byte[] codes
          lookup table for converting base64 characters to value in range 0..63
 
Constructor Summary
Base64()
           
 
Method Summary
static byte[] decode(char[] data)
          Decodes a BASE-64 encoded stream to recover the original data.
static char[] encode(byte[] data)
          returns an array of base64-encoded characters to represent the passed data array.
private static java.lang.String fromBytes(byte[] data)
          Display an array of bytes.
static void main(java.lang.String[] args)
          Main routine-test routine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alphabet

private static char[] alphabet
code characters for values 0..63


codes

private static byte[] codes
lookup table for converting base64 characters to value in range 0..63

Constructor Detail

Base64

public Base64()
Method Detail

encode

public static char[] encode(byte[] data)
returns an array of base64-encoded characters to represent the passed data array.

Parameters:
data - the array of bytes to encode
Returns:
base64-coded character array.

decode

public static byte[] decode(char[] data)
Decodes a BASE-64 encoded stream to recover the original data. White space before and after will be trimmed away, but no other manipulation of the input will be performed. As of version 1.2 this method will properly handle input containing junk characters (newlines and the like) rather than throwing an error. It does this by pre-parsing the input and generating from that a count of VALID input characters.


main

public static void main(java.lang.String[] args)
Main routine-test routine.


fromBytes

private static java.lang.String fromBytes(byte[] data)
Display an array of bytes.



Universita' di Modena e Reggio Emilia