Supported Versions: PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1
Generate a hash value (message digest)
hash(    string $algo,    string $data,    bool $binary false,    array $options = []): string
        if (! empty($token)) {

            
$user $this->provider->retrieveByCredentials([

                
$this->storageKey => $this->hash hash('sha256'$token) : $token,

            ]);

        }
        $provider m::mock(UserProvider::class);

        
$user = new AuthTokenGuardTestUser;

        
$user->id 1;

        
$provider->shouldReceive('retrieveByCredentials')->once()->with(['api_token' => hash('sha256''foo')])->andReturn($user);

        
$request Request::create('/''GET', ['api_token' => 'foo']);



        
$guard = new TokenGuard($provider$request'api_token''api_token'$hash true);
        $model->password 'secret';



        
$this->assertEquals(hash('sha256''secret'), $model->password);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->password);
        $model->password 'secret';



        
$this->assertEquals(hash('sha256''secret'), $model->password);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->password);
        $this->assertEquals(hash('sha256''secret'), $model->password);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->password);



        
$model->password 'secret2';
        $this->assertEquals(hash('sha256''secret'), $model->password);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->password);



        
$model->password 'secret2';
        $model->password 'secret2';



        
$this->assertEquals(hash('sha256''secret2'), $model->password);

        
$this->assertEquals(hash('sha256''secret2'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret2'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret2'), $model->password);
        $model->password 'secret2';



        
$this->assertEquals(hash('sha256''secret2'), $model->password);

        
$this->assertEquals(hash('sha256''secret2'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret2'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret2'), $model->password);

    }
        $this->assertEquals(hash('sha256''secret2'), $model->password);

        
$this->assertEquals(hash('sha256''secret2'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret2'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret2'), $model->password);

    }
        $this->assertEquals(hash('sha256''secret2'), $model->password);

        
$this->assertEquals(hash('sha256''secret2'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret2'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret2'), $model->password);

    }



    public function 
testSettingRawAttributesClearsTheCastCache()
    public function password(): Attribute

    
{

        return new 
Attribute(null, function ($value) {

            return 
hash('sha256'$value);

        });

    }
        $model->password 'secret';



        
$this->assertEquals(hash('sha256''secret'), $model->password);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->password);
        $model->password 'secret';



        
$this->assertEquals(hash('sha256''secret'), $model->password);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->password);
        $this->assertEquals(hash('sha256''secret'), $model->password);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->password);



        
$model->password 'secret2';
        $this->assertEquals(hash('sha256''secret'), $model->password);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->getAttributes()['password']);

        
$this->assertEquals(hash('sha256''secret'), $model->password);



        
$model->password 'secret2';