Skip to content

Instantly share code, notes, and snippets.

@ejholmes
Created April 5, 2012 01:42
Show Gist options
  • Save ejholmes/2307320 to your computer and use it in GitHub Desktop.
Save ejholmes/2307320 to your computer and use it in GitHub Desktop.
Apex class for generating an HMAC cookie for tender
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