toolkit
Hash
Hashing, password hashing and verification, and random tokens.
Hash::
Phlat\Toolkit\Hash
7 methods
Passwords
Hash::password(string $value): string
A password hash for storage.
Parameters (1)
| $value | string |
Returns string
phlat/src/Toolkit/Hash.php:17
Hash::verify(string $value, string $hash): bool
Whether $value matches a password hash.
Parameters (2)
| $value | string | |
| $hash | string |
Returns bool
phlat/src/Toolkit/Hash.php:23
Tokens
Hash::random(int $bytes = 16): string
Generates a cryptographically secure random hex string.
Parameters (1)
| $bytes | int = 16 |
Returns string
phlat/src/Toolkit/Hash.php:31
Hash::equals(string $a, string $b): bool
Timing-safe string comparison - prevents timing attacks.
Parameters (2)
| $a | string | |
| $b | string |
Returns bool
phlat/src/Toolkit/Hash.php:46
General
Hash::md5(string $value): string
The MD5 hash as hex.
For keys and cache names, never passwords.
Parameters (1)
| $value | string |
Returns string
phlat/src/Toolkit/Hash.php:54
Hash::sha256(string $value, bool $raw = false): string
The SHA-256 hash, as hex or raw bytes.
Parameters (2)
| $value | string | |
| $raw | bool = false |
Returns string
phlat/src/Toolkit/Hash.php:60