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:
- 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
-
dec_table
- A static array that maps ASCII code points to a 6-bit integer,
or -1 for an invalid code point.
-
enc_table
- A static array that maps 6-bit integers to a specific char.
-
Base64()
- Creates a Base64 transfer-encoding object.
-
decode(byte[])
- Decodes a byte array containing base64-encoded ASCII.
-
decode(String)
- Decodes a base64-encoded String.
-
encode(byte[])
- Encodes data as a String using base64 encoding.
-
encodeAsByteArray(byte[])
- Encodes data as a byte array using base64 encoding.
enc_table
protected static final char enc_table[]
- A static array that maps 6-bit integers to a specific char.
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.
Base64
public Base64()
- Creates a Base64 transfer-encoding object.
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.
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.
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.
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