public class EncodingGroovyMethods extends Object
| Constructor and Description |
|---|
EncodingGroovyMethods() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
decodeBase64(String value)
Decode the String from Base64 into a byte array.
|
static byte[] |
decodeBase64Url(String value)
Decodes a Base64 URL and Filename Safe encoded String into a byte array.
|
static byte[] |
decodeHex(String value)
Decodes a hex string to a byte array.
|
static String |
digest(byte[] self,
String algorithm)
digest the byte array
|
static String |
digest(CharSequence self,
String algorithm)
digest the CharSequence instance
|
static Writable |
encodeBase64(byte[] data)
Produce a Writable object which writes the Base64 encoding of the byte array.
|
static Writable |
encodeBase64(Byte[] data)
Produce a Writable object which writes the Base64 encoding of the byte array.
|
static Writable |
encodeBase64(byte[] data,
boolean chunked)
Produce a Writable object which writes the Base64 encoding of the byte array.
|
static Writable |
encodeBase64(Byte[] data,
boolean chunked)
Produce a Writable object which writes the Base64 encoding of the byte array.
|
static Writable |
encodeBase64Url(byte[] data)
Produce a Writable object which writes the Base64 URL and Filename Safe encoding of the byte array.
|
static Writable |
encodeBase64Url(Byte[] data)
Produce a Writable object which writes the Base64 URL and Filename Safe encoding of the byte array.
|
static Writable |
encodeBase64Url(byte[] data,
boolean pad)
Produce a Writable object which writes the Base64 URL and Filename Safe encoding of the byte array.
|
static Writable |
encodeBase64Url(Byte[] data,
boolean pad)
Produce a Writable object which writes the Base64 URL and Filename Safe encoding of the byte array.
|
static Writable |
encodeHex(byte[] data)
Produces a Writable that writes the hex encoding of the byte[].
|
static Writable |
encodeHex(Byte[] data)
Produces a Writable that writes the hex encoding of the Byte[].
|
static String |
md5(byte[] self)
Calculate md5 of the byte array
|
static String |
md5(CharSequence self)
Calculate md5 of the CharSequence instance
|
static String |
sha256(byte[] self)
Calculate SHA-256 of the byte array
|
static String |
sha256(CharSequence self)
Calculate SHA-256 of the CharSequence instance
|
public static Writable encodeBase64(Byte[] data, boolean chunked)
RFC 4648.data - Byte array to be encodedchunked - whether or not the Base64 encoded data should be MIME chunkedpublic static Writable encodeBase64(Byte[] data)
RFC 4648.data - Byte array to be encodedpublic static Writable encodeBase64(byte[] data, boolean chunked)
RFC 4648.data - byte array to be encodedchunked - whether or not the Base64 encoded data should be MIME chunkedpublic static Writable encodeBase64(byte[] data)
RFC 4648.data - byte array to be encodedpublic static Writable encodeBase64Url(Byte[] data)
RFC 4648 - Section 5
Base 64 Encoding with URL and Filename Safe Alphabet.
The method omits padding and is equivalent to calling
encodeBase64Url(Byte[], boolean) with a
value of false.
data - Byte array to be encodedencodeBase64Url(Byte[], boolean)public static Writable encodeBase64Url(Byte[] data, boolean pad)
RFC 4648 - Section 5
Base 64 Encoding with URL and Filename Safe Alphabet.data - Byte array to be encodedpad - whether or not the encoded data should be paddedpublic static Writable encodeBase64Url(byte[] data)
RFC 4648 - Section 5
Base 64 Encoding with URL and Filename Safe Alphabet.
The method omits padding and is equivalent to calling
encodeBase64Url(byte[], boolean) with a
value of false.
data - Byte array to be encodedencodeBase64Url(byte[], boolean)public static Writable encodeBase64Url(byte[] data, boolean pad)
RFC 4648 - Section 5
Base 64 Encoding with URL and Filename Safe Alphabet.data - Byte array to be encodedpad - whether or not the encoded data should be paddedpublic static byte[] decodeBase64(String value)
value - the string to be decodedpublic static byte[] decodeBase64Url(String value)
value - the string to be decodedpublic static Writable encodeHex(Byte[] data)
data - byte array to be encodedInteger.toHexString(int)public static Writable encodeHex(byte[] data)
data - byte array to be encodedInteger.toHexString(int)public static byte[] decodeHex(String value)
value - string to be decodedNumberFormatException - If the string contains an odd number of characters
or if the characters are not valid hexadecimal values.public static String md5(CharSequence self) throws NoSuchAlgorithmException
NoSuchAlgorithmException - if MD5 algorithm not foundpublic static String md5(byte[] self) throws NoSuchAlgorithmException
NoSuchAlgorithmException - if MD5 algorithm not foundpublic static String sha256(CharSequence self) throws NoSuchAlgorithmException
NoSuchAlgorithmException - if SHA-256 algorithm not foundpublic static String sha256(byte[] self) throws NoSuchAlgorithmException
NoSuchAlgorithmException - if SHA-256 algorithm not foundpublic static String digest(CharSequence self, String algorithm) throws NoSuchAlgorithmException
algorithm - the name of the algorithm requested, e.g. MD5, SHA-1, SHA-256, etc.NoSuchAlgorithmException - if the algorithm not foundMessageDigest.getInstance(java.lang.String)public static String digest(byte[] self, String algorithm) throws NoSuchAlgorithmException
algorithm - the name of the algorithm requested, e.g. MD5, SHA-1, SHA-256, etc.NoSuchAlgorithmException - if the algorithm not foundMessageDigest.getInstance(java.lang.String)