public static byte[] decode(char[] data) throws Base85FormatException {
    int length = data.length;
    byte[] out = new byte[(length / 5) * 4 + ((length % 5 != 0) ? length % 5 - 1 : 0)];
    int k = 0;
    int rest;
    int i;
    int b1, b2, b3, b4, b5;
    int b;

    for (i = 0; i + 5 <= length; i += 5) {
      b1 = decodeChar(data[i]);
      b2 = decodeChar(data[i + 1]);
      b3 = decodeChar(data[i + 2]);
      b4 = decodeChar(data[i + 3]);
      b5 = decodeChar(data[i + 4]);

      // overflow into negative numbers
      // is normal and does not do any damage because
      // of the cut operations below
      b = b1 * 52200625 + b2 * 614125 + b3 * 7225 + b4 * 85 + b5;

      out[k] = (byte)((b >>> 24) & 0xFF);
      k++;
      out[k] = (byte)((b >>> 16) & 0xFF);
      k++;
      out[k] = (byte)((b >>> 8) & 0xFF);
      k++;
      out[k] = (byte)(b & 0xFF);
      k++;
    }

    if ((rest = length % 5) != 0) {
      int j;
      char[] block = {'~', '~', '~', '~', '~'};
      for (j = 0; j < rest; j++) {
        block[j] = data[i + j];
      }
      byte[] out_rest = decode(block);
      for (j = 0; j < rest - 1; j++) {
        out[k] = out_rest[j];
        k++;
      }
    }

    return out;
  }
public static byte[] decode(char[] data)