Skip to content

Instantly share code, notes, and snippets.

Last active May 25, 2021 16:34
What would you like to do?
PHP public & private key hash
// Set timezone to UTC
// Provided public and private keys
$publicKey = 'put-your-public-key';
$privateKey = 'put-your-private-key-here';
// Capture the time and package with the public key
$time = time();
$package = $publicKey . "\n" . $time;
// SHA1 hash using the private key and then URL encode the signature
$binSignature = hash_hmac('sha1', $package, $privateKey, true);
$uriSignature = urlencode(base64_encode($binSignature));
// Put together the request URI and URL
$requestUri = "?public_key=" . $publicKey . "&time=" . $time . "&signature=" . $uriSignature;
$requestUrl = "" . $requestUri;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment