Fernet-PHP is an implementation of the Fernet token specification in PHP.
- PHP 7.0 or later
hash
extensionopenssl
ormcrypt
extensionmbstring.func_overload
needs to be switched off inphp.ini
You can install via Composer.
composer require kelvinmo/fernet-php
<?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';
}
?>
BSD 3 clause