com.spinn3r.api.util
Class Base64

java.lang.Object
  extended by com.spinn3r.api.util.Base64

public class Base64
extends java.lang.Object

Package which supplies Base64 encoding and decoding of data. This class provides encoding of byte arrays into Base64-encoded strings, and decoding the other way.

NOTE! This is modified Base64 with slightly different characters than usual, so it won't require escaping when used in URLs.

NOTE! This class only does the padding that's normal in Base64 if the 'true' flag is given to the encode() method. This is because Base64 requires that the length of the encoded text be a multiple of four characters, padded with '_'. Without the 'true' flag, we don't add these '_' characters.

Version:
$Id: Base64.java,v 1.7 2004/10/28 00:02:26 burton Exp $

Constructor Summary
Base64()
           
 
Method Summary
static byte[] decode(byte[] in)
          Handles the standards-compliant (padded with '~' signs) as well as our shortened form.
static byte[] decode(java.lang.String inStr)
          Handles the standards-compliant (padded with '~' signs) as well as our shortened form.
static java.lang.String encode(byte[] in)
           
static java.lang.String encode(byte[] in, boolean equalsPad, char[] alphabet, int limit)
          Caller should specify equalsPad=true if they want a standards compliant encoding.
static java.lang.String encode(byte[] in, int limit)
           
static byte[] encodeAsByteArray(byte[] in)
           
static byte[] encodeAsByteArray(byte[] in, boolean equalsPad, char[] alphabet)
          Caller should specify equalsPad=true if they want a standards compliant encoding.
static java.lang.String encodeFilesafe(byte[] in)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64

public Base64()
Method Detail

encode

public static java.lang.String encode(byte[] in)

encodeAsByteArray

public static byte[] encodeAsByteArray(byte[] in)

encode

public static java.lang.String encode(byte[] in,
                                      int limit)

encodeFilesafe

public static java.lang.String encodeFilesafe(byte[] in)

encode

public static java.lang.String encode(byte[] in,
                                      boolean equalsPad,
                                      char[] alphabet,
                                      int limit)
Caller should specify equalsPad=true if they want a standards compliant encoding.


encodeAsByteArray

public static byte[] encodeAsByteArray(byte[] in,
                                       boolean equalsPad,
                                       char[] alphabet)
Caller should specify equalsPad=true if they want a standards compliant encoding. The output needs to be a byte array because this is a bit more efficient for high performance work.


decode

public static byte[] decode(java.lang.String inStr)
                     throws java.lang.Exception
Handles the standards-compliant (padded with '~' signs) as well as our shortened form.

Throws:
java.lang.Exception

decode

public static byte[] decode(byte[] in)
                     throws java.lang.Exception
Handles the standards-compliant (padded with '~' signs) as well as our shortened form.

Throws:
java.lang.Exception


Copyright © Tailrank Inc. All Rights Reserved.