Skip to content

Instantly share code, notes, and snippets.

@czj
Created January 16, 2015 16:06
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/485a2f5941ebb489b5b9 to your computer and use it in GitHub Desktop.
Save czj/485a2f5941ebb489b5b9 to your computer and use it in GitHub Desktop.
FIA-NET / Certissim's HMAC SHA1 checksum
#!/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;
?>
@czj
Copy link
Author

czj commented Jan 16, 2015

Et le code d'appel en Ruby 📡

bin = Rails.root.join('bin', 'fianet_sha1_hmac')
cmd = "#{bin} '#{key}' '#{payload}'"
`#{cmd}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment