https://github.com/pforret/digestif
Digestif helps you create unique unguessable URLs (PHP)
https://github.com/pforret/digestif
laravel php security
Last synced: 3 months ago
JSON representation
Digestif helps you create unique unguessable URLs (PHP)
- Host: GitHub
- URL: https://github.com/pforret/digestif
- Owner: pforret
- License: mit
- Created: 2023-05-04T14:34:12.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-06-16T10:38:37.000Z (about 1 year ago)
- Last Synced: 2025-07-16T06:11:47.058Z (12 months ago)
- Topics: laravel, php, security
- Language: PHP
- Homepage:
- Size: 411 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Digestif helps you create unique unguessable URLs
[](https://packagist.org/packages/pforret/digestif)
[](https://github.com/pforret/digestif/actions/workflows/run-tests.yml)
[](https://packagist.org/packages/pforret/digestif)

Package to create a digest of a string/array, to be used in creating unique unguessable URLs/folder names.
## Installation
You can install the package via composer:
```bash
composer require pforret/digestif
```
## Usage
```php
use Pforret\Digestif\Digestif;
$dig = new Digestif(env("DIGEST_SEED"));
// seed value should be unique for that server/application.
// It's important that it is not known to the outside world.
// It should be the same for the application creating the Digest as the one reading/verifying it
$url = "https://secure.example.com/invoice/1200323";
// if you make your URL like this, the URL for the other invoices can be guessed (e.g. 1200324, etc)
$digest = $dig->fromString($url);
$secure_url = "$url/$digest";
// URL = https://secure.example.com/invoice/1200323/0a1b-2c3d
// using a route /invoice/{id}/{digest} will allow you to verify the digest
// the URL of the next invoice 1200324 cannot be guessed without knowing the seed value
// or use this
$secure_url = "$url?$digest";
//URL = https://secure.example.com/invoice/1200323?0a1b-2c3d
// and then verify the digest before showing the actual invoice
if(!$dig->compareDigest($dig->fromString($url), $digest)){
return false;
}
// 0a1b-2c3d will be ok, as 0a1b2c3d (without dash)
```
```
## Testing
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Peter Forret](https://github.com/pforret)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.