Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 |
|
---|
4 | class PasswordHash
|
---|
5 | {
|
---|
6 | function Hash(string $Password, string $Salt): string
|
---|
7 | {
|
---|
8 | return sha1(sha1($Password).$Salt);
|
---|
9 | }
|
---|
10 |
|
---|
11 | function Verify(string $Password, string $Salt, string $StoredHash): bool
|
---|
12 | {
|
---|
13 | return $this->Hash($Password, $Salt) == $StoredHash;
|
---|
14 | }
|
---|
15 |
|
---|
16 | function GetSalt(): string
|
---|
17 | {
|
---|
18 | mt_srand(intval(microtime(true)) * 100000 + memory_get_usage(true));
|
---|
19 | return sha1(uniqid(mt_rand(), true));
|
---|
20 | }
|
---|
21 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.