org.ka2ddo.util
Class Ascii85

java.lang.Object
  extended by org.ka2ddo.util.Ascii85

public class Ascii85
extends java.lang.Object

This class provides means to encode and decode byte arrays into ASCII85 (base-85) strings.

An ASCII85 string encodes a sequence of bytes by taking the byte data 4 bytes at a time and factoring it into modulo-85 chunks, and then converting the modulos into printable US-ASCII characters, where modulo=0 -> '!', modulo=1 -> '"', etc., up to modulo=84 -> 'u' through the US-ASCII character set. 'z' is reserved to handle the special case of a 4-byte block that is all zero.

For more information, see http://en.wikipedia.org/wiki/Ascii85 for a description of the encoding algorithm.


Method Summary
static byte[] decode(java.lang.String enc)
          Decode a String in ASCII-85 encoding into a byte array
static java.lang.String encode(byte[] sequence)
          Encode a byte array into an ASCII-95-encoded string.
static void main(java.lang.String[] args)
          unit test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public static java.lang.String encode(byte[] sequence)
Encode a byte array into an ASCII-95-encoded string.

Parameters:
sequence - byte array to encode
Returns:
encoded String

decode

public static byte[] decode(java.lang.String enc)
Decode a String in ASCII-85 encoding into a byte array

Parameters:
enc - encoded String
Returns:
byte array decoded from the String

main

public static void main(java.lang.String[] args)
unit test.

Parameters:
args - String array, ignored