mmhttp.protocol
Class Base64

java.lang.Object
  extended by mmhttp.protocol.Base64

public class Base64
extends java.lang.Object

This class supports Base 64 encoding and decoding. In this library it is primarily used for HTTP digest authentication.

 RFC 2045 - Multipurpose Internet Mail Extensions (MIME) Part One:
 Format of Internet Message Bodies
 section 6.8.  Base64 Content-Transfer-Encoding
 The encoding process represents 24-bit groups of input bits as output
 strings of 4 encoded characters.  Proceeding from left to right, a
 24-bit input group is formed by concatenating 3 8bit input groups.
 These 24 bits are then treated as 4 concatenated 6-bit groups, each
 of which is translated into a single digit in the base64 alphabet.
 When encoding a bit stream via the base64 encoding, the bit stream
 must be presumed to be ordered with the most-significant-bit first.
 That is, the first bit in the stream will be the high-order bit in
 the first 8bit byte, and the eighth bit will be the low-order bit in
 the first 8bit byte, and so on.
 


Constructor Summary
Base64()
           
 
Method Summary
static byte[] decode(byte[] bytes)
          Decodes an array of encoded bytes.
static java.lang.String decode(java.lang.String text)
          Decodes a block of Base 64 encoded text.
static byte[] encode(byte[] bytes)
          Encodes an array of bytes.
static java.lang.String encode(java.lang.String text)
          Encodes a block of text.
static byte getValueFor(byte b)
          A helper method which is public only for testing purposes.
 
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

decode

public static java.lang.String decode(java.lang.String text)
                               throws java.lang.Exception
Decodes a block of Base 64 encoded text.

Parameters:
text - to be decoded
Returns:
decoded text
Throws:
java.lang.Exception

decode

public static byte[] decode(byte[] bytes)
Decodes an array of encoded bytes.

Parameters:
bytes - to be decoded
Returns:
decoded bytes

encode

public static java.lang.String encode(java.lang.String text)
                               throws java.lang.Exception
Encodes a block of text.

Parameters:
text - to encode
Returns:
encoded text
Throws:
java.lang.Exception

encode

public static byte[] encode(byte[] bytes)
Encodes an array of bytes.

Parameters:
bytes - to encode
Returns:
encoded bytes

getValueFor

public static byte getValueFor(byte b)
A helper method which is public only for testing purposes.

Parameters:
b -
Returns:
byte


Copyright © 2009 Micah Martin. All Rights Reserved.