Class Ascii85

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

public class Ascii85 extends 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 https://en.wikipedia.org/wiki/Ascii85 for a description of the encoding algorithm.

Author:
Andrew Pavlin, KA2DDO
  • Method Details

    • encode

      public static String encode(byte[] sequence)
      Encode a byte array into an ASCII-85-encoded string.
      Parameters:
      sequence - byte array to encode
      Returns:
      encoded String
    • decode

      public static byte[] decode(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(String[] args)
      unit test.
      Parameters:
      args - String array, ignored