Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.portal.common.util
Class Base64

    java.lang.Object
      org.jboss.portal.common.util.Base64

    public class Base64

extends java.lang.Object

Encodes and decodes to and from Base64 and URL-safe Base64 encodings. URL-safe Base64 encoding being defined here as standard Base64 encoding with the following modifications:

- use '-' and '_' instead of '+' and '/'
- no line feeds
- padding character is '*' instead of '='

Based on version 2.1 of the Base64 class developed by Robert Harder (public domain). Please visit http://iharder.net/base64 periodically to check for updates or to contribute improvements.

Since:
  2.4 (Apr 30, 2006)
Author:
  Robert Harder, Chris Laprun

Method Summary
`static byte[]` | `decode(byte[] source, int off, int len, boolean urlSafeEncodingWasUsed)` Very low-level access to decoding ASCII characters in the form of a byte array.
`static byte[]` | `decode(java.lang.String s)` Decodes data from Base64 notation
`static byte[]` | `decode(java.lang.String s, boolean urlSafeEncodingWasUsed)` Decodes data from Base64 notation
`static java.lang.String` | `encodeBytes(byte[] source)` Encodes a byte array into Base64 notation using the standard Base64 encoding.
`static java.lang.String` | `encodeBytes(byte[] source, boolean useURLSafeEncoding)` Encodes a byte array into Base64 notation.
`static java.lang.String` | `encodeBytes(byte[] source, int off, int len, boolean useURLSafeEncoding)` Encodes a byte array into Base64 notation.
`void` | `initAlphabets(boolean useURLSafeEncoding)` Determine which ALPHABET to use.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### initAlphabets

    public void initAlphabets(boolean useURLSafeEncoding)

  Determine which ALPHABET to use.

### encodeBytes

    public static java.lang.String encodeBytes(byte[] source)

  Encodes a byte array into Base64 notation using the standard Base64 encoding.

  Parameters:
    `source` - The data to convert

### encodeBytes

    public static java.lang.String encodeBytes(byte[] source,
                                               boolean useURLSafeEncoding)

  Encodes a byte array into Base64 notation.

  Parameters:
    `source` - The data to convert
    `useURLSafeEncoding` - `true` to use '-', '_' instead of '+', '/' in the alphabet and '*' instead of '=' for padding to generate a URL-safe encoding. Note: Technically, this makes your encoding non-compliant.

### encodeBytes

    public static java.lang.String encodeBytes(byte[] source,
                                               int off,
                                               int len,
                                               boolean useURLSafeEncoding)

  Encodes a byte array into Base64 notation.

  Parameters:
    `source` - The data to convert
    `off` - Offset in array where conversion should begin
    `len` - Length of data to convert
    `useURLSafeEncoding` - `true` to use '-', '_' instead of '+', '/' in the alphabet and '*' instead of '=' for padding to generate a URL-safe encoding. Note: Technically, this makes your encoding non-compliant.

### decode

    public static byte[] decode(byte[] source,
                                int off,
                                int len,
                                boolean urlSafeEncodingWasUsed)

  Very low-level access to decoding ASCII characters in the form of a byte array.

  Parameters:
    `source` - The Base64 encoded data
    `off` - The offset of where to begin decoding
    `len` - The length of characters to decode
    `urlSafeEncodingWasUsed` - `true` if the URL-safe was used to encode the data to be decoded
  Returns:
    decoded data

### decode

    public static byte[] decode(java.lang.String s,
                                boolean urlSafeEncodingWasUsed)

  Decodes data from Base64 notation

  Parameters:
    `s` - the string to decode
    `urlSafeEncodingWasUsed` - `true` if the URL-safe was used to encode the data to be decoded
  Returns:
    the decoded data

### decode

    public static byte[] decode(java.lang.String s)

  Decodes data from Base64 notation

  Parameters:
    `s` - the string to decode
  Returns:
    the decoded data

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD