|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectice.cryptix.Base64
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:
Copyright © 1995-1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
Copied and modified from cryptix.util.mime.Base64.java for use in ICEsecure.
$Revision: 1.2 $
| Field Summary | |
protected static byte[] |
dec_table
A static array that maps ASCII code points to a 6-bit integer, or -1 for an invalid code point. |
protected static char[] |
enc_table
A static array that maps 6-bit integers to a specific char. |
| Constructor Summary | |
Base64()
|
|
| Method Summary | |
static byte[] |
decode(byte[] data)
Decodes a byte array containing base64-encoded ASCII. |
static byte[] |
decode(String msg)
Decodes a base64-encoded String. |
static String |
encode(byte[] data)
Encodes data as a String using base64 encoding. |
static String |
encode(byte[] data,
int linelength)
Encodes data as a String using base64 encoding. |
static byte[] |
encodeAsByteArray(byte[] data)
Encodes data as a byte array using base64 encoding. |
static byte[] |
encodeAsByteArray(byte[] data,
int linelength)
Encodes data as a byte array using base64 encoding. |
static byte[] |
getNext(byte[] encoded)
Returns the next base64 sequence in case of a concatenation of several base64 encoded objects. |
static boolean |
isBase64(byte[] encoded)
Returns true if the byte array starts with the isoLatin1 characters : " -----BEGIN", preceded or not by
whitespaces. |
static byte[] |
isoLatin1ToByteArray(String s)
Converts a String to an ISO-Latin-1 encoded byte array. |
static String |
isoLatin1ToString(byte[] b)
Converts an ISO-Latin-1 encoded byte array to a String. |
static byte[] |
removeMarkers(byte[] encoded)
Returns the first base64 encoded data bloc, removing the markers. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final char[] enc_table
protected static final byte[] dec_table
| Constructor Detail |
public Base64()
| Method Detail |
public static String encode(byte[] data)
public static String encode(byte[] data,
int linelength)
public static byte[] encodeAsByteArray(byte[] data)
public static byte[] encodeAsByteArray(byte[] data,
int linelength)
public static byte[] decode(byte[] data)
IllegalArgumentException - if data contains invalid characters,
i.e. not codes 0-32, 'A'-'Z', 'a'-'z', '+', '/'. or '=', or is
incorrectly padded.
public static byte[] decode(String msg)
throws IllegalArgumentException
IllegalArgumentException - if data contains invalid characters,
i.e. not codes 0-32, 'A'-'Z', 'a'-'z', '+', '/'. or '=', or is
incorrectly padded.public static String isoLatin1ToString(byte[] b)
This conversion function is neccessary because Java 1.1+ uses machine dependent char-to-byte and byte-to-char conversions. This is normally a useful feature, allowing machine independence. In order to maintain backwards compatibility with pre-Java conventions, we implement our own machine-independent deterministic converter.
Copied and modified from cryptix.util.mime.ISOLatin1.java
b - an array of bytes to be converted to a String.
public static byte[] isoLatin1ToByteArray(String s)
This conversion function is neccessary because Java 1.1+ uses machine dependent char-to-byte and byte-to-char conversions. This is normally a useful feature, allowing machine independence. In order to maintain backwards compatibility with pre-Java conventions, we implement our own machine-independent deterministic converter.
Copied and modified from cryptix.util.mime.ISOLatin1.java
s - the string to be converted to bytes.
IllegalArgumentException - if any of the characters in s are out of range.public static byte[] getNext(byte[] encoded)
Created for ICEsecure
public static byte[] removeMarkers(byte[] encoded)
-----BEGIN XXX-----" and "----END XXX----" lines.
Created for ICEsecure
public static boolean isBase64(byte[] encoded)
-----BEGIN", preceded or not by
whitespaces.
Created for ICEsecure
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||