moccalotto/crypto

Tiny encryption lib for PHP

0.8.1 2015-12-01 05:39 UTC

This package is not auto-updated.

Last update: 2021-02-19 22:59:16 UTC


README

Build Status

Encrypt data using aes-128-cbc. Message authentication is done via sha-256 HMAC

Installation

To add this package as a local, per-project dependency to your project, simply add a dependency on moccalotto/crypto to your project's composer.json file like so:

{
    "require": {
        "moccalotto/crypto": "~0.8"
    }
}

Alternatively simply call composer require moccalotto/crypto

Demo

<?php

use Moccalotto\Crypto\Crypto;

require 'vendor/autoload.php';

$key = 'some secret key';

$plaintext = 'This is the secret plaintext to be encrypted';

$encrypted = Crypto::with($key)->encrypt($plaintext);

echo Crypto::with($key)->decrypt($encrypted) . PHP_EOL;