vinchan / encryption
the encryption library
v1.0.2
2021-01-06 13:06 UTC
Requires
- php: >=7.1.0
This package is not auto-updated.
Last update: 2025-03-27 10:17:40 UTC
README
composer require vinchan/encryption
说明:
AES
openssl_encrypt("加密的数据","AES-128-CBC",密码,"OPENSSL_RAW_DATA",$iv);
openssl_decrypt("解密的数据","AES-256-CBC",密码,"OPENSSL_RAW_DATA",$iv);
RSA
openssl_private_decrypt ("解密的数据","解密后的数据",密钥,"OPENSSL_PKCS1_PADDING");
openssl_private_encrypt ("加密的数据","加密后的数据",密钥,"OPENSSL_PKCS1_PADDING");
openssl_public_decrypt ("解密的数据","解密后的数据",密钥,"OPENSSL_PKCS1_PADDING");
openssl_public_decrypt ("加密的数据","加密后的数据",密钥,"OPENSSL_PKCS1_PADDING");
二:使用方式
1.加密使用
/**
*@param string $key 加密的KEY
*@param string $defaultEncrypt 加密方式(私钥/公钥加密) private/public
*@param string $data 被加密的数据
*/
Factory::RSA()->key($key)->defaultEncrypt($defaultEncrypt)->encrypt($data);
Factory::AES()->key($key)->option($option)->iv($iv)->encrypt($data);
2.解密使用
/**
*@param string $key 解密的KEY
*@param string $defaultEncrypt 解密方式(私钥/公钥解密) private/public
*@param string $data 被解密的数据
*/
Factory::RSA()->key($key)->defaultEncrypt($defaultEncrypt)->decrypt($data);
Factory::AES()->key($key)->option($option)->iv($iv)->decrypt($data);