Skip to content

Instantly share code, notes, and snippets.

@samwize
Created December 14, 2012 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samwize/4283632 to your computer and use it in GitHub Desktop.
Save samwize/4283632 to your computer and use it in GitHub Desktop.
Compute signature of a http from Hoiio. This is used to authenticate the notification from Hoiio. Match this computed signature with the HTTP header "X-Hoiio-Signature".
public String computeHoiioSignature(byte[] payload, String accessToken) {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(payload);
md.update(accessToken.getBytes("UTF-8"));
byte[] bytes = md.digest();
String mySign = Hex.encodeHexString(bytes);
return mySign;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment