Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Hashing;
4
 
5
use RuntimeException;
6
 
7
class Argon2IdHasher extends ArgonHasher
8
{
9
    /**
10
     * Check the given plain value against a hash.
11
     *
12
     * @param  string  $value
13
     * @param  string|null  $hashedValue
14
     * @param  array  $options
15
     * @return bool
16
     *
17
     * @throws \RuntimeException
18
     */
19
    public function check($value, $hashedValue, array $options = [])
20
    {
21
        if ($this->verifyAlgorithm && $this->info($hashedValue)['algoName'] !== 'argon2id') {
22
            throw new RuntimeException('This password does not use the Argon2id algorithm.');
23
        }
24
 
25
        if (is_null($hashedValue) || strlen($hashedValue) === 0) {
26
            return false;
27
        }
28
 
29
        return password_verify($value, $hashedValue);
30
    }
31
 
32
    /**
33
     * Get the algorithm that should be used for hashing.
34
     *
35
     * @return int
36
     */
37
    protected function algorithm()
38
    {
39
        return PASSWORD_ARGON2ID;
40
    }
41
}