Pluf Framework

Sign in or create your account | Project List | Help

Pluf Framework Commit Details

Date:2010-02-03 13:15:18 (1 month 18 days ago)
Author:Loïc d'Anterroches
Commit:1050261a272731eca2ef3e8e83d8d73e81022ed1
Message:Correctly use the builtin function.

Files: src/Pluf/Sign.php (1 diff)

Change Details

src/Pluf/Sign.php
165165     */
166166    public static function base64_hmac($value, $key)
167167    {
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));
192169    }
193170}

Archive Download the corresponding diff file

Branches:
master