Lucid Hash
Note: Your URL should include the entire URL, including the trailing &
Hash Me
How does this work?
Python
import hmac
import hashlib
import base64
encoded_key = key.encode('utf-8')
encoded_URL = URL.encode('utf-8')
hashed = hmac.new(encoded_key, msg=encoded_URL, digestmod=hashlib.sha1)
digested_hash = hashed.digest()
base64_encoded_result = base64.b64encode(digested_hash)
final_result = base64_encoded_result.decode('utf-8').replace('+', '-').replace('/', '_').replace('=', '')
PHP
$encoded_key = utf8_encode($key);
$encoded_URL = utf8_encode($URL);
$hashed = hash_hmac('sha1', $encoded_URL, $encoded_key);
$digested_hash = pack('H*',$hashed);
$base64_encoded_result = base64_encode($digested_hash);
$final_result = str_replace(["+","/","="],["-","_",""],utf8_decode($base64_encoded_result))
Node.js
const Crypto = require('crypto');
const hash = Crypto.createHmac('sha1', key).update(url, 'utf-8').digest('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
const final_result = encodeURIComponent(hash);
Java
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;
private static String hashMe(String url, String keyString) throws
UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(key);
byte[] bytes = mac.doFinal(url.getBytes("UTF-8"));
byte[] encodedBytes = Base64.getEncoder().encode(bytes);
String finalResult = new String(encodedBytes);
return finalResult.replace("+", "-").replace("/", "_").replace("=", "");
}
About Lucid Hash
Generate Base64 SHA-1 output. Hash it good.