src/Http/Response.php
function digestAuth(array $users, array $options = array())
    {
        $realm = &$options['realm'];
        if (null === $realm) {
            $realm = 'CP Login Required';
        }

        $digest = &$_SERVER['PHP_AUTH_DIGEST'];
        if ($digest) {
            $data = $this->httpDigestParse($digest);
            if (isset($data['username']) && isset($users[$data['username']])) {
                $A1 = md5($data['username'] . ':' . $realm . ':' . $users[$data['username']]);
                $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']);
                $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2);
                if (0 === strcmp($valid_response, $data['response'])) {
                    $_SERVER['CP_AUTH_USER'] = $data['username'];
                    return;
                }
            }
        }

        $message = &$options['fail_msg'];
        if (null === $message) {
            $message = self::$statusDescriptions[401];
        }

        $nonce = &$options['nonce'];
        if (null === $nonce) {
            $nonce = uniqid();
        }

        $this->setResponseStatus(401)
            ->setHeader('WWW-Authenticate: Digest realm="' . $realm .
                '",qop="auth",nonce="' . $nonce . '",opaque="' . md5($realm) . '"')
            ->displayOver($message);
    }
function digestAuth(array $users, array $options = array())
    {
        $realm = &$options['realm'];
        if (null === $realm) {
            $realm = 'CP Login Required';
        }

        $digest = &$_SERVER['PHP_AUTH_DIGEST'];
        if ($digest) {
            $data = $this->httpDigestParse($digest);
            if (isset($data['username']) && isset($users[$data['username']])) {
                $A1 = md5($data['username'] . ':' . $realm . ':' . $users[$data['username']]);
                $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']);
                $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2);
                if (0 === strcmp($valid_response, $data['response'])) {
                    $_SERVER['CP_AUTH_USER'] = $data['username'];
                    return;
                }
            }
        }

        $message = &$options['fail_msg'];
        if (null === $message) {
            $message = self::$statusDescriptions[401];
        }

        $nonce = &$options['nonce'];
        if (null === $nonce) {
            $nonce = uniqid();
        }

        $this->setResponseStatus(401)
            ->setHeader('WWW-Authenticate: Digest realm="' . $realm .
                '",qop="auth",nonce="' . $nonce . '",opaque="' . md5($realm) . '"')
            ->displayOver($message);
    }
digest authentication

@param array $users ['user' => 'password']
@param array $options