plectrum/加密

加密服务库

1.0.3 2023-07-17 11:45 UTC

This package is auto-updated.

Last update: 2024-09-17 14:49:28 UTC


README

加密服务是一个PHP库,使用AES-256-CBC加密算法提供加密和解密功能。它允许您使用密钥安全地加密敏感数据,并通过解密获取原始数据。

主要功能

  • 使用AES-256-CBC加密算法加密数据
  • 解密加密数据
  • 输入验证以确保提供所需的变量
  • 处理解密失败和无效数据时的错误

安装

使用composer安装库

composer require plectrum/encryption

使用方法

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.