正文  软件开发 > PHP编程技术 >

OAuth认证协议中的HMACSHA1加密算法,oauthhmacsha1

OAuth认证协议中的HMACSHA1加密算法,oauthhmacsha1<?php function hmacsha1($key,$data) { $blocksize=64; ...

OAuth认证协议中的HMACSHA1加密算法,oauthhmacsha1

<?php
function hmacsha1($key,$data) {
    $blocksize=64;
    $hashfunc=‘sha1‘;
    if (strlen($key)>$blocksize)
        $key=pack(‘H*‘, $hashfunc($key));
    $key=str_pad($key,$blocksize,chr(0x00));
    $ipad=str_repeat(chr(0x36),$blocksize);
    $opad=str_repeat(chr(0x5c),$blocksize);
    $hmac = pack(
                ‘H*‘,$hashfunc(
                    ($key^$opad).pack(
                        ‘H*‘,$hashfunc(
                            ($key^$ipad).$data
                        )
                    )
                )
            );
    return $hmac;
}
?>

http://www.bkjia.com/PHPjc/1230277.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1230277.htmlTechArticleOAuth认证协议中的HMACSHA1加密算法,oauthhmacsha1 ? php function hmacsha1( $key , $data ) { $blocksize =64 ; $hashfunc =‘sha1‘ ; if ( strlen ( $key ) $blocksize ) $key =...