-
Notifications
You must be signed in to change notification settings - Fork 11.1k
/
HashManager.php
124 lines (112 loc) · 2.9 KB
/
HashManager.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
namespace Illuminate\Hashing;
use Illuminate\Contracts\Hashing\Hasher;
use Illuminate\Support\Manager;
/**
* @mixin \Illuminate\Contracts\Hashing\Hasher
*/
class HashManager extends Manager implements Hasher
{
/**
* Create an instance of the Bcrypt hash Driver.
*
* @return \Illuminate\Hashing\BcryptHasher
*/
public function createBcryptDriver()
{
return new BcryptHasher($this->config->get('hashing.bcrypt') ?? []);
}
/**
* Create an instance of the Argon2i hash Driver.
*
* @return \Illuminate\Hashing\ArgonHasher
*/
public function createArgonDriver()
{
return new ArgonHasher($this->config->get('hashing.argon') ?? []);
}
/**
* Create an instance of the Argon2id hash Driver.
*
* @return \Illuminate\Hashing\Argon2IdHasher
*/
public function createArgon2idDriver()
{
return new Argon2IdHasher($this->config->get('hashing.argon') ?? []);
}
/**
* Get information about the given hashed value.
*
* @param string $hashedValue
* @return array
*/
public function info($hashedValue)
{
return $this->driver()->info($hashedValue);
}
/**
* Hash the given value.
*
* @param string $value
* @param array $options
* @return string
*/
public function make(#[\SensitiveParameter] $value, array $options = [])
{
return $this->driver()->make($value, $options);
}
/**
* Check the given plain value against a hash.
*
* @param string $value
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function check(#[\SensitiveParameter] $value, $hashedValue, array $options = [])
{
return $this->driver()->check($value, $hashedValue, $options);
}
/**
* Check if the given hash has been hashed using the given options.
*
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function needsRehash($hashedValue, array $options = [])
{
return $this->driver()->needsRehash($hashedValue, $options);
}
/**
* Determine if a given string is already hashed.
*
* @param string $value
* @return bool
*/
public function isHashed(#[\SensitiveParameter] $value)
{
return $this->driver()->info($value)['algo'] !== null;
}
/**
* Get the default driver name.
*
* @return string
*/
public function getDefaultDriver()
{
return $this->config->get('hashing.driver', 'bcrypt');
}
/**
* Verifies that the configuration is less than or equal to what is configured.
*
* @param array $value
* @return bool
*
* @internal
*/
public function verifyConfiguration($value)
{
return $this->driver()->verifyConfiguration($value);
}
}