/fernet-php

An implementation of the Fernet token specification in PHP.

Primary LanguagePHPOtherNOASSERTION

Fernet-PHP

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