kelvinmo / fernet-php
An implementation of the Fernet token specification in PHP.
v1.0.1
2022-02-22 07:18 UTC
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
hashextensionopensslormcryptextensionmbstring.func_overloadneeds 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