org.restlet.engine.util

## Class Base64

- java.lang.Object
- - org.restlet.engine.util.Base64

    public class Base64
    extends java.lang.Object

Minimal but fast Base64 codec.

Author:
  Ray Waldin (ray@waldin.net)

### Constructor Summary

Constructors
Constructor and Description
`Base64()`

### Method Summary

Methods
`static byte[]` `decode(char[] chars)` Decodes base64 characters into bytes.
`static byte[]` `decode(java.lang.String encodedString)` Decodes a base64 string into bytes.
`static java.lang.String` `encode(byte[] bytes, boolean newlines)` Encodes an entire byte array into a Base64 string, with optional newlines after every 76 characters.
`static java.lang.String` `encode(byte[] bytes, int off, int len, boolean newlines)` Encodes specified bytes into a Base64 string, with optional newlines after every 76 characters.
`static java.lang.String` `encode(char[] chars, boolean newlines)` Encodes an entire chars array into a Base64 string, with optional newlines after every 76 characters.
`static java.lang.String` `encode(char[] chars, java.lang.String charset, boolean newlines)` Encodes an entire chars array into a Base64 string, with optional newlines after every 76 characters.

### 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 byte[] decode(char[] chars)

Decodes base64 characters into bytes. Newline characters found at block boundaries will be ignored.

Parameters:
  `chars` - The characters array to decode.
Returns:
  The decoded byte array.

#### decode

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

Decodes a base64 string into bytes. Newline characters found at block boundaries will be ignored.

Parameters:
  `encodedString` - The string to decode.
Returns:
  The decoded byte array.

#### encode

    public static java.lang.String encode(byte[] bytes,
                          boolean newlines)

Encodes an entire byte array into a Base64 string, with optional newlines after every 76 characters.

Parameters:
  `bytes` - The byte array to encode.
  `newlines` - Indicates whether or not newlines are desired.
Returns:
  The encoded string.

#### encode

    public static java.lang.String encode(byte[] bytes,
                          int off,
                          int len,
                          boolean newlines)

Encodes specified bytes into a Base64 string, with optional newlines after every 76 characters.

Parameters:
  `bytes` - The byte array to encode.
  `off` - The starting offset.
  `len` - The number of bytes to encode.
  `newlines` - Indicates whether or not newlines are desired.
Returns:
  The encoded string.

#### encode

    public static java.lang.String encode(char[] chars,
                          boolean newlines)

Encodes an entire chars array into a Base64 string, with optional newlines after every 76 characters.

Parameters:
  `chars` - The characters array to encode.
  `newlines` - Indicates whether or not newlines are desired.
Returns:
  The encoded string.

#### encode

    public static java.lang.String encode(char[] chars,
                          java.lang.String charset,
                          boolean newlines)

Encodes an entire chars array into a Base64 string, with optional newlines after every 76 characters.

Parameters:
  `chars` - The characters array to encode.
  `charset` - The character set to use for the character to byte conversion.
  `newlines` - Indicates whether or not newlines are desired.
Returns:
  The encoded string.