Guest User

Untitled

a guest
Feb 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. private String getMac(String RequestString, String secretkey) {
  2. String algorithmName = ‘hmacSHA1′; // the other options are: hmacMD5, hmacSHA256, and hmacSHA512
  3. Blob input = Blob.valueOf(RequestString);
  4. Blob signing =Crypto.generateMac(algorithmName, input, secretkey);
  5. String str=EncodingUtil.urlEncode(EncodingUtil.base64Encode(signing), ‘UTF-8′);
  6.  
  7. String str=EncodingUtil.base64Encode(signing);
  8.  
  9. string timestamp1 = datetime.now().formatGmt('EEE, d MMM yyyy HH:mm:ss Z');
  10. String action = 'Action';
  11. String algorithmName = 'HMACSHA256';
  12. Blob mac = Crypto.generateMac(algorithmName, Blob.valueOf(timestamp1),
  13. Blob.valueOf(Secretkey));
  14. String macUrl =EncodingUtil.base64Encode(mac);
Add Comment
Please, Sign In to add comment