java.lang.Object
org.seppiko.commons.utils.codec.Base32
- All Implemented Interfaces:
Serializable,BaseNCodec
Base32 encoding and decoding.
- Author:
- Leonard Woo
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Base32The most widely used Base32 alphabet is defined in RFC 4648.static final Base32The most widely used Base32 alphabet is defined in RFC 4648.static final Base32z-base-32 is a Base32 encoding designed by Zooko Wilcox-O'Hearn to be easier for human use and more compact.Fields inherited from interface org.seppiko.commons.utils.codec.BaseNCodec
BIT_WIDTH, BITS_PER_ENCODED_BYTE, BYTES_PER_ENCODED_BLOCK, MASK_2BITS, MASK_4BITS, MASK_5BITS, MASK_6BITS, MASK_8BITS, MASK_UPPER_4BITS -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Decode the Base32-encoded data in input and return the data in a new byte array.encodeString(byte[] source) Base32-encode the given data and return a newly allocated String with the result.
-
Field Details
-
RFC4648
The most widely used Base32 alphabet is defined in RFC 4648. It uses an alphabet of A–Z, followed by 2–7. The digits 0, 1 and 8 are skipped due to their similarity with the letters O, I and B (thus "2" has a decimal value of 26). -
RFC4648_HEX
The most widely used Base32 alphabet is defined in RFC 4648. It uses a digit of 0-9, followed by A–V. -
ZBASE32
z-base-32 is a Base32 encoding designed by Zooko Wilcox-O'Hearn to be easier for human use and more compact. It includes 1, 8 and 9 but excludes l, v and 2. It also permutes the alphabet so that the easier characters are the ones that occur more frequently.- See Also:
-
-
Method Details
-
encodeString
Base32-encode the given data and return a newly allocated String with the result.- Specified by:
encodeStringin interfaceBaseNCodec- Parameters:
source- the data to encode.- Returns:
- a newly allocated String with the result.
- Throws:
NullPointerException- data isnull.
-
decode
Decode the Base32-encoded data in input and return the data in a new byte array.- Specified by:
decodein interfaceBaseNCodec- Parameters:
str- the data to decode.- Returns:
- the data in a new byte array.
- Throws:
IllegalArgumentException- data is not divisible by 8.NullPointerException- data isnull.
-