Constructor and Description |
---|
BaseX(String alphabet,
boolean caseSensitive,
char padding)
Constructs an encoder/decoder using the given characters.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
decode(String in)
Decodes the given base-X string into bytes, silently ignoring any
non-base-X characters.
|
StringBuffer |
encode(byte[] in,
int off,
int len,
String sep,
int freq)
Encodes the given bytes into a base-X string, optionally inserting a
separator into the result with given frequency.
|
public BaseX(String alphabet, boolean caseSensitive, char padding)
alphabet
- the encoding alphabet: the characters to use in the encoded
form. The length of this string must be an exact power of 2
and the characters must be distinct.caseSensitive
- if true
, both the encoder and decoder are
case-sensitive; if false
, the encoder always produces
exactly the characters in alphabet
, but decoder
accepts both upper- and lower-case forms as equal.padding
- the padding character used to even out the length of the
encoded output. This must not appear in the encoding alphabet.public final StringBuffer encode(byte[] in, int off, int len, String sep, int freq)
in
- an array containing the bytes to encode.off
- the start offset of the data within in
.len
- the number of bytes to encode.sep
- if sep
is not null
and freq
is
positive, the sep
is inserted into the result between
blocks of freq
normal characters.freq
- if sep
is not null
and freq
is
positive, the sep
is inserted into the result between
blocks of freq
normal characters.public final byte[] decode(String in)
in
- the string to decode.Copyright © 2024 Guardtime. All rights reserved.