Package org.cryptacular.codec
Class Base64Encoder
java.lang.Object
org.cryptacular.codec.AbstractBaseNEncoder
org.cryptacular.codec.Base64Encoder
- All Implemented Interfaces:
Encoder
Stateful base 64 encoder with support for configurable line breaks.
- Author:
- Middleware Services
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder for base-64 encoders. -
Field Summary
Fields inherited from class org.cryptacular.codec.AbstractBaseNEncoder
lineLength
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance that produces base 64-encoded output with no line breaks in the default character set.Base64Encoder
(boolean urlSafe) Creates a new instance that produces base 64-encoded output with no line breaks and optional URL-safe character set.Base64Encoder
(boolean urlSafe, int charactersPerLine) Creates a new instance that produces base 64-encoded output with the given number of characters per line with the option of URL-safe character set.Base64Encoder
(int charactersPerLine) Creates a new instance that produces base 64-encoded output with the given number of characters per line in the default character set.Base64Encoder
(String alphabet) Creates a new instance that produces base 64-encoded output with the given 64-character alphabet.Base64Encoder
(String alphabet, int charactersPerLine) Creates a new instance that produces base 64-encoded output with the given 64-character alphabet with line wrapping at the specified line length; -
Method Summary
Methods inherited from class org.cryptacular.codec.AbstractBaseNEncoder
encode, encodingTable, finalize, isPaddedOutput, outputSize, setPaddedOutput
-
Constructor Details
-
Base64Encoder
public Base64Encoder()Creates a new instance that produces base 64-encoded output with no line breaks in the default character set. -
Base64Encoder
public Base64Encoder(boolean urlSafe) Creates a new instance that produces base 64-encoded output with no line breaks and optional URL-safe character set.- Parameters:
urlSafe
- True to use URL and filesystem-safe character set, false otherwise.
-
Base64Encoder
public Base64Encoder(int charactersPerLine) Creates a new instance that produces base 64-encoded output with the given number of characters per line in the default character set.- Parameters:
charactersPerLine
- Number of characters per line. A zero or negative value disables line breaks.
-
Base64Encoder
public Base64Encoder(boolean urlSafe, int charactersPerLine) Creates a new instance that produces base 64-encoded output with the given number of characters per line with the option of URL-safe character set.- Parameters:
urlSafe
- True to use URL and filesystem-safe character set, false otherwise.charactersPerLine
- Number of characters per line. A zero or negative value disables line breaks.
-
Base64Encoder
Creates a new instance that produces base 64-encoded output with the given 64-character alphabet.- Parameters:
alphabet
- 64-character alphabet to use.
-
Base64Encoder
Creates a new instance that produces base 64-encoded output with the given 64-character alphabet with line wrapping at the specified line length;- Parameters:
alphabet
- 64-character alphabet to use.charactersPerLine
- Number of characters per line. A zero or negative value disables line breaks.
-
-
Method Details
-
getBlockLength
protected int getBlockLength()- Specified by:
getBlockLength
in classAbstractBaseNEncoder
- Returns:
- Number of bits in a block of encoded characters.
-
getBitsPerChar
protected int getBitsPerChar()- Specified by:
getBitsPerChar
in classAbstractBaseNEncoder
- Returns:
- Number of bits encoding a single character.
-