Skip to content

Instantly share code, notes, and snippets.

@czj
Created January 16, 2015 09:41
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 czj/033c14538aa01f1d10e7 to your computer and use it in GitHub Desktop.
Save czj/033c14538aa01f1d10e7 to your computer and use it in GitHub Desktop.
FIANET / Certissim SHA1 + HMAC signature
#!/usr/bin/php
<?php
// Check http://cl.ly/2o0z0z1G103O for documentation on Certissim's HMAC SHA1
// First parameter = hexadecimal key
$key_hex = $argv[1];
// Second = string to get signature
$payload = $argv[2];
// Convert to binary string
$key_bytes = pack('H*', $key_hex);
// SHA1 with binary string key
$auth = hash_hmac('sha1', $payload, $key_bytes, FALSE);
echo $auth;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment