function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Encoding psuedo code to apex

Hi, I was hoping for some help changing the following psuedo code to apex.


Signature = URL-Encode( Base64( HMAC-SHA1( YourSecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) ) );


Heres what I've written so far, but theres something off:


stringToSign = EncodingUtil.urlEncode(stringToSign, 'UTF-8');
Blob mac = Crypto.generateMac('hmacSHA1',  Blob.valueOf(stringToSign), Blob.valueOf('xxx'));
stringToSign = EncodingUtil.base64Encode(mac);
String encoded = EncodingUtil.urlEncode(stringToSign, 'UTF-8');