superwaba.ext.xplat.io.http
Class Base64

java.lang.Object
  |
  +--superwaba.ext.xplat.io.http.Base64

public class Base64
extends java.lang.Object

Class with methods to encode and decode to base 64. The base 64 is used to convert binaries into text so that they can be sent over a stream. It may then be converted back to binary form.

Note that 3 bytes base 16 (hexadecimal) are encoded into 4 bytes base 64, so the final length is 33% bigger.

Since:
SuperWaba 5.1

Field Summary
static int[] toBase10
          Convertion table from base 64 to base 10
static char[] toBase64
          Convertion table from base 10 to base 64
 
Constructor Summary
Base64()
           
 
Method Summary
static void decode(ByteArrayStream in, ByteArrayStream out)
          Decodes a given base 64 stream into a base 10 stream.
static byte[] decode(java.lang.String inStr)
          Decodes the given string into a byte array with the exact size.
static java.lang.String encode(byte[] bytes)
          Encodes the given byte array and returns a base 64 generated String
static void encode(ByteArrayStream in, ByteArrayStream out)
          Encodes a given base 10 stream into a base 64 stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

toBase64

public static final char[] toBase64
Convertion table from base 10 to base 64

toBase10

public static int[] toBase10
Convertion table from base 64 to base 10
Constructor Detail

Base64

public Base64()
Method Detail

decode

public static void decode(ByteArrayStream in,
                          ByteArrayStream out)
Decodes a given base 64 stream into a base 10 stream. Important: error detection is NOT made, so you must be sure that no invalid characters are given!
Parameters:
in - The Base 64 input stream. Its position must be set to the current size of the input data.
out - The Base 10 output stream. When returning, its position will be set with the output size in bytes.

decode

public static byte[] decode(java.lang.String inStr)
Decodes the given string into a byte array with the exact size.

encode

public static java.lang.String encode(byte[] bytes)
Encodes the given byte array and returns a base 64 generated String

encode

public static void encode(ByteArrayStream in,
                          ByteArrayStream out)
Encodes a given base 10 stream into a base 64 stream.
Parameters:
in - The Base 10 output stream. Its position must be set to the current size of the input data.
out - The Base 64 input stream. When returning, its position will be set with the output size in bytes.