Any ideas what I am doing wrong?
Data = '1605470404trashed';
Private Key = '5034eafbf7068b76e4762db248effd77';
Algoithm: SHA256
Actual HMAC generated from service = e4911d1d188c24d313a159d38f1beb06e56c53f87ae0833820aef7c3a3812b96
When I use this service I get the correct HMAC:
https://www.freeformatter.com/hmac-generator.html
When I use this code in salesforce to verify it returns false:
Crypto.verifyHmac(
'hmacSHA256',
blob.valueOf('1605470404trashed'),
blob.valueOf('5034eafbf7068b76e4762db248effd77'),
blob.valueOf('e4911d1d188c24d313a159d38f1beb06e56c53f87ae0833820aef7c3a3812b96')
);
And when I try to generate the same HMAC I get a value that is nowhere near the result expected:
Blob bdata = Blob.valueOf('1605470404trashed');
Blob encrypted = Crypto.generateMac('HmacSHA256',bdata, blob.valueOf('5034eafbf7068b76e4762db248effd77'));
System.debug( EncodingUtil.base64Encode(encrypted));
returns: X4u/2/COJQR1yxUmDcxIp5BxcgYxLz+0X08FB4Bg5Oc=
Any ideas how to verify the HMAC e4911d1d188c24d313a159d38f1beb06e56c53f87ae0833820aef7c3a3812b96 in salesforce using the above information?
Part about generating HMAC is answered by Generating HMAC message digest via Crypto class
Still curious why verifyHMAC
returns false. Maybe it cannot be used for this use case?