kelvinmo / fernet-php
An implementation of the Fernet token specification in PHP.
Installs: 765 933
Dependents: 3
Suggesters: 0
Security: 0
Stars: 20
Watchers: 2
Forks: 6
Open Issues: 0
Requires
- php: ^7.0 || ^8.0
- ext-hash: *
Requires (Dev)
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ^6.0 || ^9.0
Suggests
- ext-mcrypt: This package requires either the mcrypt or openssl extension.
- ext-openssl: This package requires either the mcrypt or openssl extension.
README
Fernet-PHP is an implementation of the Fernet token specification in PHP.
Requirements
- PHP 7.0 or later
hash
extensionopenssl
ormcrypt
extensionmbstring.func_overload
needs to be switched off inphp.ini
Installation
You can install via Composer.
composer require kelvinmo/fernet-php
Usage
<?php require 'vendor/autoload.php'; use Fernet\Fernet; $key = '[Base64url encoded fernet key]'; $fernet = new Fernet($key); $token = $fernet->encode('string message'); $message = $fernet->decode('fernet token'); if ($message === null) { echo 'Token is not valid'; } ?>
License
BSD 3 clause