src/Http/Auth.php
public static function encode($username, $password, $data = [])
    {
        if (!isset($data['nonce'])) {
            $response = base64_encode("{$username}:{$password}");
            return compact('username', 'response');
        }
        $defaults = [
            'realm' => 'app', 'method' => 'GET', 'uri' => '/', 'qop' => null,
            'cnonce' => md5(time()), 'nc' => static::$nc
        ];
        $data = array_filter($data) + $defaults;
        $part1 = md5("{$username}:{$data['realm']}:{$password}");
        $part2 = "{$data['nonce']}:{$data['nc']}:{$data['cnonce']}:{$data['qop']}";
        $part3 = md5($data['method'] . ':' . $data['uri']);
        $response = md5("{$part1}:{$part2}:{$part3}");
        return compact('username', 'response') + $data;
    }
public static function encode($username, $password, $data = [])
    {
        if (!isset($data['nonce'])) {
            $response = base64_encode("{$username}:{$password}");
            return compact('username', 'response');
        }
        $defaults = [
            'realm' => 'app', 'method' => 'GET', 'uri' => '/', 'qop' => null,
            'cnonce' => md5(time()), 'nc' => static::$nc
        ];
        $data = array_filter($data) + $defaults;
        $part1 = md5("{$username}:{$data['realm']}:{$password}");
        $part2 = "{$data['nonce']}:{$data['nc']}:{$data['cnonce']}:{$data['qop']}";
        $part3 = md5($data['method'] . ':' . $data['uri']);
        $response = md5("{$part1}:{$part2}:{$part3}");
        return compact('username', 'response') + $data;
    }
public static function encode ( $ username , $ password , $ data = [ ] ) { if ( ! isset ( $ data [ 'nonce' ] ) ) { $ response = base64_encode ( "{$username}:{$password}" ) ; return compact ( 'username' , 'response' ) ; } $ defaults = [ 'realm' => 'app' , 'method' => 'GET' , 'uri' => '/' , 'qop' => null , 'cnonce' => md5 ( time ( ) ) , 'nc' => static :: $ nc ] ; $ data = array_filter ( $ data ) + $ defaults ; $ part1 = md5 ( "{$username}:{$data['realm']}:{$password}" ) ; $ part2 = "{$data['nonce']}:{$data['nc']}:{$data['cnonce']}:{$data['qop']}" ; $ part3 = md5 ( $ data [ 'method' ] . ':' . $ data [ 'uri' ] ) ; $ response = md5 ( "{$part1}:{$part2}:{$part3}" ) ; return compact ( 'username' , 'response' ) + $ data ; }
Encodes the data with username and password to create the proper response. Returns an array
containing the username and encoded response.

@param  string $username Username to authenticate with
@param  string $password Password to authenticate with
@param  array  $data Params needed to hash the response
@return array
Encodes the data with username and password to create the proper response . Returns an array containing the username and encoded response .