All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cryptix.util.mime.Base64

java.lang.Object
   |
   +----cryptix.util.mime.Base64

public class Base64
extends Object
This class provides methods for encoding and decoding data in MIME base64 format.

The input to the encode methods is always a byte array. Strictly speaking the output represents a sequence of characters, but since these characters are from a subset of both the Unicode and ASCII character repertoires, it is possible to express the output either as a String or as a byte array.

References:

  1. RFC 2045, Multipurpose Internet Mail Extensions (MIME) Part One, Format of Internet Message Bodies, "Section 6.8 Base64 Content-Transfer-Encoding," http://www.imc.org/rfc2045

Copyright © 1995-1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.1.1.1 $

Author:
Jill Baker, David Hopwood

Variable Index

 o dec_table
A static array that maps ASCII code points to a 6-bit integer, or -1 for an invalid code point.
 o enc_table
A static array that maps 6-bit integers to a specific char.

Constructor Index

 o Base64()
Creates a Base64 transfer-encoding object.

Method Index

 o decode(byte[])
Decodes a byte array containing base64-encoded ASCII.
 o decode(String)
Decodes a base64-encoded String.
 o encode(byte[])
Encodes data as a String using base64 encoding.
 o encodeAsByteArray(byte[])
Encodes data as a byte array using base64 encoding.

Variables

 o enc_table
 protected static final char enc_table[]
A static array that maps 6-bit integers to a specific char.

 o dec_table
 protected static final byte dec_table[]
A static array that maps ASCII code points to a 6-bit integer, or -1 for an invalid code point.

Constructors

 o Base64
 public Base64()
Creates a Base64 transfer-encoding object.

Methods

 o encode
 public String encode(byte data[])
Encodes data as a String using base64 encoding. Line breaks in the output are represented as CR LF.

Returns:
the encoded string.
 o encodeAsByteArray
 public byte[] encodeAsByteArray(byte data[])
Encodes data as a byte array using base64 encoding. The characters 'A'-'Z', 'a'-'z', '0'-'9', '+', '/', and '=' in the output are mapped to their ASCII code points. Line breaks in the output are represented as CR LF (codes 13 and 10).

Returns:
the encoded byte array.
 o decode
 public byte[] decode(byte data[])
Decodes a byte array containing base64-encoded ASCII. Characters with ASCII code points <= 32 (this includes whitespace and newlines) are ignored.

Returns:
the decoded data.
Throws: IllegalArgumentException
if data contains invalid characters, i.e. not codes 0-32, 'A'-'Z', 'a'-'z', '+', '/'. or '=', or is incorrectly padded.
 o decode
 public byte[] decode(String msg) throws IllegalArgumentException
Decodes a base64-encoded String. Characters with ASCII code points <= 32 (this includes whitespace and newlines) are ignored.

Returns:
the decoded data.
Throws: IllegalArgumentException
if data contains invalid characters, i.e. not codes 0-32, 'A'-'Z', 'a'-'z', '+', '/'. or '=', or is incorrectly padded.

All Packages  Class Hierarchy  This Package  Previous  Next  Index