kiwi.text
Class Radix64Codec

java.lang.Object
  |
  +--kiwi.text.Radix64Codec

public class Radix64Codec
extends Object

This class implements a codec for the Radix-64 encoding scheme. For a high-level interface, see the Radix64InputStream and Radix64OutputStream filters in kiwi.io.

This codec implements Radix-64 as defined by the PGP software.

Version:
1.0 (10/98)
Author:
Mark Lindner, PING Software Group
See Also:
Radix64InputStream, Radix64OutputStream

Method Summary
static int decode(byte[] input, byte[] output)
          Decode 4 bytes of printable ASCII text into up to 3 bytes of binary data.
static byte[] encode(byte[] input, int len)
          Encode up to 3 bytes of binary data as 4 bytes of printable ASCII text.
static boolean isRadix64Character(byte c)
          Determine if a byte is a valid Radix-64 encoding character; one of the characters: '+', '/', '=', '0' - '9', 'A' - 'Z', 'a' - 'z'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isRadix64Character

public static final boolean isRadix64Character(byte c)
Determine if a byte is a valid Radix-64 encoding character; one of the characters: '+', '/', '=', '0' - '9', 'A' - 'Z', 'a' - 'z'.
Parameters:
c - The byte to test.
Returns:
true if c is a Radix-64 character, false otherwise.

encode

public static final byte[] encode(byte[] input,
                                  int len)
Encode up to 3 bytes of binary data as 4 bytes of printable ASCII text.
Parameters:
input - A 3-byte long array of input.
len - The number of bytes (1, 2, or 3) that are significant in the input.
Returns:
A 4-byte array of printable characters that represent the Radix-64 encoding of the input. The output will include padding ('=' characters) if not all 3 bytes of the input were significant.

decode

public static final int decode(byte[] input,
                               byte[] output)
Decode 4 bytes of printable ASCII text into up to 3 bytes of binary data.
Parameters:
input - A 4-byte long array of input bytes.
output - A 3-byte long array in which up to 3 bytes of decoded output will be stored.
Returns:
The number of bytes decoded (1, 2, or 3).