Git Product home page Git Product logo

fyreencryption's Introduction

FyreEncryption

FyreEncryption is a free, encryption library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/encryption

In PHP:

use Fyre\Encryption\Encryption;

Methods

Clear

Clear all instances and configs.

Encryption::clear();

Get Config

Set an encrypter config.

  • $key is a string representing the encrypter key.
$config = Encryption::getConfig($key);

Alternatively, if the $key argument is omitted an array containing all configurations will be returned.

$config = Encryption::getConfig();

Get Key

Get the key for an encrypter instance.

  • $encrypter is a Encrypter.
$key = Encryption::getKey($encrypter);

Load

Load an encrypter.

  • $options is an array containing configuration options.
$encrypter = Encryption::load($options);

Set Config

Set the encrypter config.

  • $key is a string representing the encrypter key.
  • $options is an array containing configuration options.
Encryption::setConfig($key, $options);

Alternatively, a single array can be provided containing key/value of configuration options.

Encryption::setConfig($config);

Unload

Unload an encrypter.

  • $key is a string representing the encrypter key, and will default to "default".
Encryption::unload($key);

Use

Load a shared encrypter instance.

  • $key is a string representing the encrypter key, and will default to "default".
$encrypter = Encryption::use($key);

Encrypters

You can load a specific encrypter by specifying the className option of the $options variable above.

Custom encrypters can be created by extending \Fyre\Encryption\Encrypter, ensuring all below methods are implemented.

Decrypt

Decrypt data.

  • $data is the encrypted data.
  • $key is a string representing the encryption key.
$decrypted = $encrypter->decrypt($data, $key);

Encrypt

Encrypt data.

  • $data is the data to encrypt.
  • $key is a string representing the encryption key.
$encrypted = $encrypter->encrypt($data, $key);

Generate Key

Generate an encryption key.

$key = $encrypter->generateKey();

OpenSSL

The OpenSSL encrypter can be loaded using default configuration using the "openssl" key.

$encrypter = Encryption::use('openssl');

You can also load the encrypter using custom configuration.

  • $key is a string representing the encrypter key.
  • $options is an array containing configuration options.
    • className must be set to \Fyre\Encryption\Handlers\OpenSSLEncrypter.
    • cipher is a string indicating the cipher, and will default to "AES-256-CTR".
Encryption::setConfig($key, $options);

$encrypter = Encryption::use($key);

Sodium

The Sodium encrypter is the default handler.

$encrypter = Encryption::use();

You can also load the encrypter using custom configuration.

  • $key is a string representing the encrypter key.
  • $options is an array containing configuration options.
    • className must be set to \Fyre\Encryption\Handlers\SodiumEncrypter.
    • blockSize is a number indicating the block size, and will default to 16.
Encryption::setConfig($key, $options);

$encrypter = Encryption::use($key);

fyreencryption's People

Contributors

elusivecodes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.