Skip to content

Instantly share code, notes, and snippets.

@cwarden
Created February 15, 2013 16:47
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 cwarden/4961642 to your computer and use it in GitHub Desktop.
Save cwarden/4961642 to your computer and use it in GitHub Desktop.
<?php
function validateSignedRequest($signedRequest, $key) {
list($signature, $payload) = explode('.', $signedRequest);
$hmac = base64_encode(hash_hmac('sha256', $payload, $key, true));
return $signature == $hmac;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment