| 1 | <?php |
||
| 16 | final class Hash |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * Hash Parameter. |
||
| 20 | * |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | private $hash; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Hash Length. |
||
| 27 | * |
||
| 28 | * @var int |
||
| 29 | */ |
||
| 30 | private $length; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @return Hash |
||
| 34 | */ |
||
| 35 | public static function sha1(): Hash |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return Hash |
||
| 42 | */ |
||
| 43 | public static function sha256(): Hash |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return Hash |
||
| 50 | */ |
||
| 51 | public static function sha384(): Hash |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return Hash |
||
| 58 | */ |
||
| 59 | public static function sha512(): Hash |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @param string $hash |
||
| 66 | * @param int $length |
||
| 67 | */ |
||
| 68 | private function __construct(string $hash, int $length) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @return int |
||
| 76 | */ |
||
| 77 | public function getLength(): int |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Compute the HMAC. |
||
| 84 | * |
||
| 85 | * @param string $text |
||
| 86 | * |
||
| 87 | * @return string |
||
| 88 | */ |
||
| 89 | public function hash(string $text): string |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @return string |
||
| 96 | */ |
||
| 97 | public function name(): string |
||
| 101 | } |
||
| 102 |