0

Using JMETER, I would like to convert below String in SHA - 256 Hash key notation

624111NUL2021-10-06T11:35:39-04:00NULs3cr3tNUL,

The correct supposed to be

7c3f952cdd1d6bf56a2762c5bb94add00883654794d27344f1dd55e5901f381c

while using below hash function

${__digest(SHA-256,624111NUL2021-10-06T11:35:39-04:00NULs3cr3tNUL,,,)}

Unfortunately not getting the correct result from the above function, I came to know, NUL characters between the fields and at the end (3 total NUL characters). These are hex 00 characters. They show as NUL in Notepad++ but they are really hex 00. e.g. Id+ "\000" + timestamp + "\000" + salt + "\000"

Any idea to manage the same in JMeter to get correct SHA 256 Key

Narendra
  • 1
  • 1

1 Answers1

0

Just go for __groovy() function which allows executing arbitrary Groovy code where you can have Unicode escape sequences:

${__groovy(org.apache.commons.codec.digest.DigestUtils.sha256Hex('624111\0002021-10-06T11:35:39-04:00\000s3cr3t\000'),)}

enter image description here

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thanks a lot @Dmitri :-), It's working.. – Narendra Oct 11 '21 at 11:52
  • Hi @@Dmitri, Hope you are doing well. Need your help again, if you are aware How to use BCrypt in place of SHA256 in groovy function what you shared few months back. – Narendra Jul 25 '22 at 15:36