webnarmin/cryptor

A simple encryption and decryption library

v1.0.1 2024-06-28 20:59 UTC

This package is auto-updated.

Last update: 2025-02-28 22:53:31 UTC


README

A simple PHP library for encrypting and decrypting data using AES-256-CBC.

Installation

You can install the Cryptor library via Composer. Run the following command in your project directory:

composer require webnarmin/cryptor

Usage

Here's a quick example of how to use the Cryptor class:

Encrypting Data

<?php

require 'vendor/autoload.php';

use webnarmin\Cryptor\Cryptor;

$privateKey = 'your_private_key';
$publicKey = 'your_public_key';
$data = 'Hello, world!';

$cryptor = new Cryptor($privateKey);
$encryptedData = $cryptor->encrypt($data, $publicKey);

echo 'Encrypted Data: ' . $encryptedData;

Decrypting Data

<?php

require 'vendor/autoload.php';

use webnarmin\Cryptor\Cryptor;

$privateKey = 'your_private_key';
$publicKey = 'your_public_key';
$encryptedData = 'your_encrypted_data';

$cryptor = new Cryptor($privateKey);
$decryptedData = $cryptor->decrypt($encryptedData, $publicKey);

echo 'Decrypted Data: ' . $decryptedData;

Running Tests

To run tests, you need to have PHPUnit installed. If you don't have it installed, you can install it via Composer:

composer require --dev phpunit/phpunit

Run the tests using the following command:

vendor/bin/phpunit

License

This library is licensed under the MIT License.