delboy1978uk / bone-crypt
基于openssl的加密/解密类
v1.0.2
2021-11-13 14:25 UTC
Requires
- ext-json: *
- ext-openssl: *
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-13 20:43:28 UTC
README
安装
通过composer安装
composer require delboy1978uk/bone-crypt
用法
加密和解密一个值
use Bone\Crypt\Crypt; $crypt = new Crypt(); // returns array with key, IV, tag, and ciphertext $encrypted = $crypt->encrypt('Super secret data'); // Take the key out of the array and json encode $key = $encrypted['key']; unset($encrypted['key']); // this is your payload. Save the key somewhere! $json = \json_encode($encrypted); // To decrypt $result = $this->crypt->decrypt($json, $key); // 'Super secret data'