PHP sample code for the signature calculation
<?php
// Encode a string to base64
function encodeBase64Safe($value)
{
return str_replace(array('+', '/'), array('-', '_'),
base64_encode($value));
}
// Decode a string from base64
function decodeBase64Safe($value)
{
return base64_decode(str_replace(array('-', '_'), array('+', '/'),
$value));
}
// Sign a command with a given crypto key
// Note that this command must be properly encoded
function SignedCommand($itemToCheck, $privateKey)
{
// Decode the private key into its binary format
$decodedKey = decodeBase64Safe($privateKey);
// Create a signature using the private key and the URL-encoded
// string using HMAC SHA1. This signature will be binary.
$signature = hash_hmac("sha1",$itemToCheck, $decodedKey, true);
$encodedSignature = encodeBase64Safe($signature);
return $encodedSignature;
}
echo SignedCommand("COMMAND_ITEM_TO_SIGN", 'YOUR_PRIVATE_KEY');
?>