PHP public & private key hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Set timezone to UTC | |
date_default_timezone_set('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 = "https://api.rapidspike.com/v1/assets" . $requestUri; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment