plectrum/encryption

Encryption service library

1.0.3 2023-07-17 11:45 UTC

This package is auto-updated.

Last update: 2025-06-17 16:20:15 UTC


README

Encryption Service is a PHP library that provides encryption and decryption functionalities using AES-256-CBC cipher. It allows you to securely encrypt sensitive data using a secret key and retrieve the original data through decryption.

Main features:

  • Encryption of data using AES-256-CBC cipher
  • Decryption of encrypted data
  • Input validation to ensure required variables are provided
  • Error handling for decryption failures and invalid data

Installation

Install the library using composer:

composer require plectrum/encryption

Usage

require __DIR__ . '/vendor/autoload.php';

use Plectrum\Encryption\EncryptionService;

$encryption = new EncryptionService();

$data = array('id'=>1);
$secretKey='Your Secret Key';

//for encryption

$encryptedData = $encryption->encrypt($data,$secretKey);
echo $encryptedData;

//for decryption
$decryptedData = $encryption->decrypt($encryptedData,$secretKey);
 print_r($decryptedData);

Make sure to replace `data` and `secretKey` with the appropriate values for encryption and decryption.