apex code - Salesforce creating incorrect HMAC SHA1 value -
i'm trying generate hmac value within salesforce using crypto generatemac function, result doesn't match other utilities.
for example, i'm trying hash value hash me
using key ac67ad3b8771bf63d4fa9582845a18f921514f36
. i'm expecting result 66fe419859ac42ad88354dfa52f2196a26d767e1
, it's 7d1f56c728dfefdcb9edb72b7c0c8df2acf1cae9
.
my apex code is:
blob mac = crypto.generatemac('hmacsha1', blob.valueof('hash me'), blob.valueof('33a1211c0ee01511ccba1e456bb95503')); string hasedvalue = encodingutil.converttohex(mac);
i'm guessing issue related converting to/from binary or maybe related case, cannot match expected result.
my expected result based on result http://hash.online-convert.com/sha1-generator , couple other online hmac calculators.
the other option base 64 encode:
encodingutil.base64encode(mac);
i'd surprised if generatemac + converttohex aren't working you. they've worked me. i'm sure you've looked, in case i'd go on amazon web services example in documentation.
Comments
Post a Comment