From a8e3d36f8092266b825e54d53efa7c8f035836b2 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Wed, 16 May 2012 13:45:36 +0200 Subject: [PATCH] use urldecode(http_build_request()) instead of looping and building request string --- ykval-common.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ykval-common.php b/ykval-common.php index e0bfba5..fdfc0b1 100644 --- a/ykval-common.php +++ b/ykval-common.php @@ -88,15 +88,7 @@ function UnixToDbTime($unix) // return b64 encoded hmac hash function sign($a, $apiKey) { ksort($a); - $qs = ''; - $n = count($a); - $i = 0; - foreach (array_keys($a) as $key) { - $qs .= trim($key).'='.trim($a[$key]); - if (++$i < $n) { - $qs .= '&'; - } - } + $qs = urldecode(http_build_query($a)); // the TRUE at the end states we want the raw value, not hexadecimal form $hmac = hash_hmac('sha1', utf8_encode($qs), $apiKey, true);