Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | /** |
| 4 | * Pop PHP Framework (https://www.popphp.org/) |
| 5 | * |
| 6 | * @link https://github.com/popphp/popphp-framework |
| 7 | * @author Nick Sagona, III <nick@popphp.org> |
| 8 | * @copyright Copyright (c) 2009-2026 Nick Sagona, III |
| 9 | * @license https://www.popphp.org/license New BSD License |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * @namespace |
| 14 | */ |
| 15 | namespace Pop\Crypt\Hashing; |
| 16 | |
| 17 | /** |
| 18 | * Pop Crypt hashing interface |
| 19 | * |
| 20 | * @category Pop |
| 21 | * @package Pop\Crypt |
| 22 | * @author Nick Sagona, III <nick@popphp.org> |
| 23 | * @copyright Copyright (c) 2009-2026 Nick Sagona, III |
| 24 | * @license https://www.popphp.org/license New BSD License |
| 25 | * @version 4.0.0 |
| 26 | */ |
| 27 | interface HasherInterface |
| 28 | { |
| 29 | |
| 30 | /** |
| 31 | * Make hashed value (based on the hasher class) |
| 32 | * |
| 33 | * @param string $value |
| 34 | * @return string |
| 35 | */ |
| 36 | public function make(#[\SensitiveParameter] string $value): string; |
| 37 | |
| 38 | /** |
| 39 | * Determine if the hashed value requires re-hashing (based on the hasher class) |
| 40 | * |
| 41 | * @param string $hashedValue |
| 42 | * @return bool |
| 43 | */ |
| 44 | public function requiresRehash(string $hashedValue): bool; |
| 45 | |
| 46 | /** |
| 47 | * Set hasher options |
| 48 | * |
| 49 | * @param array $options |
| 50 | * @return static |
| 51 | */ |
| 52 | public function setOptions(array $options): static; |
| 53 | |
| 54 | /** |
| 55 | * Create hasher object with options |
| 56 | * |
| 57 | * @return static |
| 58 | */ |
| 59 | public static function create(array $options = []): static; |
| 60 | |
| 61 | /** |
| 62 | * Create hashed value |
| 63 | * |
| 64 | * @param string $value |
| 65 | * @param string|int|null $algorithm |
| 66 | * @param array $options |
| 67 | * @throws Exception |
| 68 | * @return string |
| 69 | */ |
| 70 | public function createHash(#[\SensitiveParameter] string $value, string|int|null $algorithm, array $options = []): string; |
| 71 | |
| 72 | /** |
| 73 | * Get info from hashed value |
| 74 | * |
| 75 | * @param string $hashedValue |
| 76 | * @return array |
| 77 | */ |
| 78 | public function getInfo(string $hashedValue): array; |
| 79 | |
| 80 | /** |
| 81 | * Get available hashing algorithms |
| 82 | * |
| 83 | * @return array |
| 84 | */ |
| 85 | public function getAlgorithms(): array; |
| 86 | |
| 87 | /** |
| 88 | * Determine if the hashed value needs to be re-hashed |
| 89 | * |
| 90 | * @param string $hashedValue |
| 91 | * @param string|int|null $algorithm |
| 92 | * @param array $options |
| 93 | * @return bool |
| 94 | */ |
| 95 | public function needsRehash(string $hashedValue, string|int|null $algorithm, array $options = []): bool; |
| 96 | |
| 97 | /** |
| 98 | * Verify hash |
| 99 | * |
| 100 | * @param string $value |
| 101 | * @param string $hashedValue |
| 102 | * @throws Exception |
| 103 | * @return bool |
| 104 | */ |
| 105 | public function verify(#[\SensitiveParameter] string $value, string $hashedValue): bool; |
| 106 | |
| 107 | } |