Last active
March 2, 2020 09:51
-
-
Save chinlung/94a5a854afd3b6eae8178eef3e69c127 to your computer and use it in GitHub Desktop.
Used to encode a field for Auth #hex2b64 #php
This file contains hidden or 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
function hex2b64($str) | |
{ | |
$raw = ''; | |
for ($i = 0; $i < strlen($str); $i += 2) { | |
$raw .= chr(hexdec(substr($str, $i, 2))); | |
} | |
return base64_encode($raw); | |
} | |
/* | |
Example: | |
$signature = hex2b64(hash_hmac('sha1', $data, $secret_key)); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment