Skip to Content

SHA256 conversion in Groovy script to be used in HCI

Dear Experts,

We are trying to convert input string to SHA256 algorithm, this option is not available in standard conversion methods.

Can anyone help me with Groovy script on this?

This is what I tested online and it's working fine.

When I tried same in HCI I got the error. I am trying to put the input string body to be converted. Please suggest.

import java.util.HashMap;
def Message processData(Message message) {
	def body = message.getBody( String input );
	def digest ="SHA-256");
	digest.update( input.bytes );
	new BigInteger(1,digest.digest()).toString(16).padLeft(32, '0');
	return message;



1.jpg (41.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Feb 07, 2018 at 11:53 AM

    Hi Thouheed

    Some of the variables from the two code snippets got a bit jumbled up. The lines for getting the message body and updating the digest, should be something like the following:

    def body = message.getBody(java.lang.String) as String // Gets the message body as a String
    digest.update(body.bytes) // Updates the digest with the bytes of the message body



    Add comment
    10|10000 characters needed characters exceeded