moccalotto / crypto
Tiny encryption lib for PHP
Installs: 28
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/moccalotto/crypto
Requires
- php: >=5.6.0
- ext-openssl: *
Requires (Dev)
- phpspec/phpspec: ~2.0
This package is not auto-updated.
Last update: 2025-09-27 23:42:02 UTC
README
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;