uru917 uru917 - 1 month ago 16
Groovy Question

How to generate a hexdigest with Groovy?

I need to sign a request with AWS 4 but I am having issues with the Signature key.

From Amazon Doc

Use the digest (binary format) for the key derivation. Most languages have functions to compute either a binary format hash, commonly called a digest, or a hex-encoded hash, called a hexdigest. The key derivation requires that you use a binary-formatted digest.

So I am able to obtain the Signature key in
format but I am not able to format that value as hexdigest.

Rao Rao
Answer Source

Is it something that you are looking for? .encodeHex()

byte[] printable = 'Rao'.bytes
println printable
def printableHex = printable.encodeHex()
println printableHex.toString()