Created
April 5, 2012 01:42
-
-
Save ejholmes/2307320 to your computer and use it in GitHub Desktop.
Apex class for generating an HMAC cookie for tender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Tender { | |
public static String TENDER_SECRET = 'monkey'; | |
public static String DOMAIN = 'help.yourapp.com'; | |
public static String tenderize(String username) { | |
String expires = '1228117891'; | |
String input = DOMAIN + '/' + username + '/' + expires; | |
Blob hmac = Crypto.generateMac('hmacSHA1', Blob.valueOf(input), Blob.valueOf(TENDER_SECRET)); | |
return EncodingUtil.convertToHex(hmac); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment