1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-02-01 10:52:18 +01:00

use urldecode(http_build_request()) instead of looping and building request string

This commit is contained in:
Klas Lindfors 2012-05-16 13:45:36 +02:00
parent 2e0dbfa2c3
commit a8e3d36f80

View File

@ -88,15 +88,7 @@ function UnixToDbTime($unix)
// return b64 encoded hmac hash // return b64 encoded hmac hash
function sign($a, $apiKey) { function sign($a, $apiKey) {
ksort($a); ksort($a);
$qs = ''; $qs = urldecode(http_build_query($a));
$n = count($a);
$i = 0;
foreach (array_keys($a) as $key) {
$qs .= trim($key).'='.trim($a[$key]);
if (++$i < $n) {
$qs .= '&';
}
}
// the TRUE at the end states we want the raw value, not hexadecimal form // the TRUE at the end states we want the raw value, not hexadecimal form
$hmac = hash_hmac('sha1', utf8_encode($qs), $apiKey, true); $hmac = hash_hmac('sha1', utf8_encode($qs), $apiKey, true);