根據
A1=MD5(
A2=MD5(
最後結果:MD5(MD5(A1):
注意上面一行的MD5(A1)和MD5(A2)是有問題的,瀏覽器實作為MD5(A1:
$realm='saberyjs';
$password='0011';//這個地方式要查詢資料庫的,只是測試方便而已;
if(!isset($_SERVER['PHP_AUTH_DIGEST']))
{
$n> {
$n> real-cate ',nonce='".$nonce."',algorithm='md5',qop='auth'");
header("HTTP/1.0 401 Unauthorization Required");
{
//echo 'sset';
//echo $_SERVER['PHP_AUTH_DIGEST'];
_$result=parse_auth_dig; //var_dump($result);
//echo hexdec ($result['nc']);
//exit();
if((int)$result['nc']>1)
$n> header("www-authenticate:Digest realm ='".$realm."',nonce='".$nonce."',algorithm='md5',qop='auth'");
1.0 401 Unauthorization Required");
exit();
我realm'].":".$password);
//$A1=md5($result['username'].':'.$result['realm'].':'.$password).':'.$result['nonce'].':' .$result['cnonce'];
$A2=md5($_SERVER['REQUEST_METHOD'].":".$result['uri']);
$degest=md:$degest=md:$A1. result['nonce'].':'.$result['nc'].':'.$result['cnonce'].':'.$result['qop'].':'.$A2) ;
// var_dump($degest);
if($degest!=$result['response'])
{ var_dump($result);
}
else
{
echo成功';
}
}
function parse_auth_digest($auth_digest))); preg_match_all('/(w+)=['"]?([/a-z0-9A-Z .]+)['"]?/i',$auth_digest,$result,PREG_SET_ORDER);
foreach($result as $value)
$pairs[$value[1] =$ /var_dump($pairs);
return $pairs;
}
?>
以上就介紹了php摘要認證,包含了面向的內容,希望對PHP教學有興趣的朋友有幫助。