Change Details
| src/Pluf/Sign.php |
| 165 | 165 | */ |
| 166 | 166 | public static function base64_hmac($value, $key) |
| 167 | 167 | { |
| 168 | | return Pluf_Utils::urlsafe_b64encode(self::hmac_sha1($key, $value)); |
| 169 | | } |
| 170 | | |
| 171 | | |
| 172 | | |
| 173 | | /** |
| 174 | | * HMAC-SHA1 function. |
| 175 | | * |
| 176 | | * @see http://us.php.net/manual/en/function.sha1.php#39492 |
| 177 | | * |
| 178 | | * @param string Key |
| 179 | | * @param string Data |
| 180 | | * @return string Calculated binary HMAC-SHA1 |
| 181 | | */ |
| 182 | | public static function hmac_sha1($key, $data) |
| 183 | | { |
| 184 | | if (strlen($key) > 64) { |
| 185 | | $key = pack('H*', sha1($key)); |
| 186 | | } |
| 187 | | $key = str_pad($key, 64, chr(0x00)); |
| 188 | | $ipad = str_repeat(chr(0x36), 64); |
| 189 | | $opad = str_repeat(chr(0x5c), 64); |
| 190 | | return pack('H*',sha1(($key^$opad).pack('H*',sha1(($key^$ipad).$data)))); |
| 191 | | return bin2hex($hmac); |
| 168 | return Pluf_Utils::urlsafe_b64encode(hash_hmac('sha1', $value, $key, true)); |
| 192 | 169 | } |
| 193 | 170 | } |
Download the corresponding diff file