public class EncodingGroovyMethods extends Object
This class defines all the encoding/decoding groovy methods which enhance the normal JDK classes when inside the Groovy environment. Static methods are used with the first parameter the destination class.
Type Params | Return Type | Name 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(CharSequence self, String algorithm) digest the CharSequence instance |
|
static String |
digest(byte[] self, String algorithm) digest 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) 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) 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, boolean pad) 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 |
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(CharSequence self) Calculate md5 of the CharSequence instance |
|
static String |
md5(byte[] self) Calculate md5 of the byte array |
|
static String |
sha256(CharSequence self) Calculate SHA-256 of the CharSequence instance |
|
static String |
sha256(byte[] self) Calculate SHA-256 of the byte array |
|
String |
toString() |
|
String |
toString() |
|
Writer |
writeTo(Writer writer) |
|
Writer |
writeTo(Writer out) |
Decode the String from Base64 into a byte array.
value
- the string to be decodedDecodes a Base64 URL and Filename Safe encoded String into a byte array.
value
- the string to be decodedDecodes a hex string to a byte array. The hex string can contain either upper case or lower case letters.
value
- string to be decodeddigest the CharSequence instance
algorithm
- the name of the algorithm requested, e.g. MD5, SHA-1, SHA-256, etc.digest the byte array
algorithm
- the name of the algorithm requested, e.g. MD5, SHA-1, SHA-256, etc. Produce a Writable object which writes the Base64 encoding of the byte array.
Calling toString() on the result returns the encoding as a String. For more
information on Base64 encoding and chunking see RFC 4648
.
data
- Byte array to be encodedchunked
- whether or not the Base64 encoded data should be MIME chunked Produce a Writable object which writes the Base64 encoding of the byte array.
Calling toString() on the result returns the encoding as a String. For more
information on Base64 encoding and chunking see RFC 4648
.
data
- Byte array to be encoded Produce a Writable object which writes the Base64 encoding of the byte array.
Calling toString() on the result returns the encoding as a String. For more
information on Base64 encoding and chunking see RFC 4648
.
data
- byte array to be encodedchunked
- whether or not the Base64 encoded data should be MIME chunked Produce a Writable object which writes the Base64 encoding of the byte array.
Calling toString() on the result returns the encoding as a String. For more
information on Base64 encoding and chunking see RFC 4648
.
data
- byte array to be encoded Produce a Writable object which writes the Base64 URL and Filename Safe encoding of the byte array.
Calling toString() on the result returns the encoding as a String. For more
information on Base64 URL and Filename Safe encoding see RFC 4648 - Section 5
Base 64 Encoding with URL and Filename Safe Alphabet
.
The method omits padding and is equivalent to calling
EncodingGroovyMethods.encodeBase64Url with a
value of false
.
data
- Byte array to be encoded Produce a Writable object which writes the Base64 URL and Filename Safe encoding of the byte array.
Calling toString() on the result returns the encoding as a String. For more
information on Base64 URL and Filename Safe encoding see 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 padded Produce a Writable object which writes the Base64 URL and Filename Safe encoding of the byte array.
Calling toString() on the result returns the encoding as a String. For more
information on Base64 URL and Filename Safe encoding see RFC 4648 - Section 5
Base 64 Encoding with URL and Filename Safe Alphabet
.
The method omits padding and is equivalent to calling
EncodingGroovyMethods.encodeBase64Url with a
value of false
.
data
- Byte array to be encoded Produce a Writable object which writes the Base64 URL and Filename Safe encoding of the byte array.
Calling toString() on the result returns the encoding as a String. For more
information on Base64 URL and Filename Safe encoding see 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 paddedProduces a Writable that writes the hex encoding of the Byte[]. Calling toString() on this Writable returns the hex encoding as a String. The hex encoding includes two characters for each byte and all letters are lower case.
data
- byte array to be encodedProduces a Writable that writes the hex encoding of the byte[]. Calling toString() on this Writable returns the hex encoding as a String. The hex encoding includes two characters for each byte and all letters are lower case.
data
- byte array to be encodedCalculate md5 of the CharSequence instance
Calculate md5 of the byte array
Calculate SHA-256 of the CharSequence instance
Calculate SHA-256 of the byte array