kelvinmo/fernet-php

An implementation of the Fernet token specification in PHP.

v1.0.1 2022-02-22 07:18 UTC

This package is auto-updated.

Last update: 2024-12-22 13:29:13 UTC


README

Latest Stable Version Build Status

Fernet-PHP is an implementation of the Fernet token specification in PHP.

Requirements

  • PHP 7.0 or later
  • hash extension
  • openssl or mcrypt extension
  • mbstring.func_overload needs to be switched off in php.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