Download the PHP package horsev/expiring-key-generator without Composer
On this page you can find all versions of the php package horsev/expiring-key-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download horsev/expiring-key-generator
More information about horsev/expiring-key-generator
Files in horsev/expiring-key-generator
Package expiring-key-generator
Short Description Generate date-based expiring keys with SHA256 hashing and time-window validation
License MIT
Informations about the package expiring-key-generator
expiring-key-generator (PHP)
Generate date-based keys and validate them within a time window. Uses a secret alphabet for base-N encoding + SHA256 hashing.
PHP port of expiring-key-generator — keys are cross-compatible with the same secret.
- Zero dependencies (besides PHP 8.1+)
- Algorithmic generation
- No database needed
Install
Usage
API
generateSecretKey(): string
Returns a randomly shuffled 34-character string from a safe alphabet (A-Z without O, 1-9 without 0).
createKeyGenerator(string $secretKey): Closure
Throws if $secretKey is not a valid 34-character permutation of the safe alphabet.
Returns fn(DateTimeInterface $date): string that encodes a date into a deterministic base64 SHA256 hash.
createKeyValidator(string $secretKey): Closure
Throws if $secretKey is invalid.
Returns fn(string $hash, DateTimeInterface $currentDate, int $days): bool that checks whether a key was generated within the last $days days.
createHourlyKeyGenerator(string $secretKey): Closure
Returns fn(DateTimeInterface $date): string that encodes date+hour into a hash. Uses YYYYMMDDHH (10 digits).
createHourlyKeyValidator(string $secretKey): Closure
Returns fn(string $hash, DateTimeInterface $currentDate, int $hours): bool for 1–24 hour windows.
License
MIT