Package org.cryptacular.util
Class CodecUtil
java.lang.Object
org.cryptacular.util.CodecUtil
Utility class for common encoding conversions.
- Author:
- Middleware Services
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
b32
(byte[] raw) Encodes bytes into base 32-encoded string.static String
b32
(byte[] raw, int lineLength) Encodes bytes into base32-encoded string.static byte[]
b32
(CharSequence encoded) Decodes a base32-encoded string into raw bytes.static String
b64
(byte[] raw) Encodes bytes into base 64-encoded string.static String
b64
(byte[] raw, int lineLength) Encodes bytes into base64-encoded string.static byte[]
b64
(CharSequence encoded) Decodes a base64-encoded string into raw bytes.static byte[]
decode
(Decoder decoder, CharSequence encoded) Decodes the given encoded data using the given char-to-byte decoder.static String
Encodes raw bytes using the given encoder.static String
hex
(byte[] raw) Encodes raw bytes to the equivalent hexadecimal encoded string.static String
hex
(byte[] raw, boolean delimit) Encodes raw bytes to the equivalent hexadecimal encoded string with optional delimiting of output.static byte[]
hex
(CharSequence encoded) Decodes a hexadecimal encoded string to raw bytes.
-
Method Details
-
hex
Encodes raw bytes to the equivalent hexadecimal encoded string.- Parameters:
raw
- Raw bytes to encode.- Returns:
- Hexadecimal encoded string.
- Throws:
EncodingException
- on encoding errors.
-
hex
Encodes raw bytes to the equivalent hexadecimal encoded string with optional delimiting of output.- Parameters:
raw
- Raw bytes to encode.delimit
- True to delimit every two characters (i.e. every byte) of output with ':' character, false otherwise.- Returns:
- Hexadecimal encoded string.
- Throws:
EncodingException
- on encoding errors.
-
hex
Decodes a hexadecimal encoded string to raw bytes.- Parameters:
encoded
- Hex encoded character data.- Returns:
- Raw bytes of hex string.
- Throws:
EncodingException
- on decoding errors.
-
b64
Encodes bytes into base 64-encoded string.- Parameters:
raw
- Raw bytes to encode.- Returns:
- Base64-encoded string.
- Throws:
EncodingException
- on encoding errors.
-
b64
Decodes a base64-encoded string into raw bytes.- Parameters:
encoded
- Base64-encoded character data.- Returns:
- Base64-decoded bytes.
- Throws:
EncodingException
- on decoding errors.
-
b64
Encodes bytes into base64-encoded string.- Parameters:
raw
- Raw bytes to encode.lineLength
- Length of each base64-encoded line in output.- Returns:
- Base64-encoded string.
- Throws:
EncodingException
- on encoding errors.
-
b32
Encodes bytes into base 32-encoded string.- Parameters:
raw
- Raw bytes to encode.- Returns:
- Base32-encoded string.
- Throws:
EncodingException
- on encoding errors.
-
b32
Decodes a base32-encoded string into raw bytes.- Parameters:
encoded
- Base32-encoded character data.- Returns:
- Base64-decoded bytes.
- Throws:
EncodingException
- on decoding errors.
-
b32
Encodes bytes into base32-encoded string.- Parameters:
raw
- Raw bytes to encode.lineLength
- Length of each base32-encoded line in output.- Returns:
- Base32-encoded string.
- Throws:
EncodingException
- on encoding errors.
-
encode
Encodes raw bytes using the given encoder.- Parameters:
encoder
- Encoder to perform byte-to-char conversion.raw
- Raw bytes to encode.- Returns:
- Encoded data as a string.
- Throws:
EncodingException
- on encoding errors.
-
decode
Decodes the given encoded data using the given char-to-byte decoder.- Parameters:
decoder
- Decoder to perform char-to-byte conversion.encoded
- Encoded character data.- Returns:
- Decoded data as raw bytes.
- Throws:
EncodingException
- on decoding errors.
-