rasalas/easycrypt
Composer 安装命令:
composer require rasalas/easycrypt
包简介
turns array data or strings in url safe(optional) signed crypt strings and can decrypt them again and make sure it's the same data
README 文档
README
EasyCrypt helps to easily encrypt data with a simple passphrase.
What is it for?
It encrypts array data or strings that you might want to append to your URL as GET data. Or maybe you want to put it in a hidden input. All yours to decide.
If someone tampered with the data, you'll notice, as it's going to return false instead of with data (this might change). That's also what's the $salt is for. EasyCrypt signs the data and checks if the data is still unchanged.
Please DO NOT use this to store user data or other sensitive data.
Installation
rasa@home:~$ composer require rasalas/easycrypt
Example usage
<?php // import require __DIR__ . '/vendor/autoload.php'; // or include('vendor/rasalas/easycrypt/src/class.easycrypt.php'); $ez = new Rasalas\Tools\EasyCrypt('supersecurepassphrase', 'saltandpepper'); // test data $data = ['user_id'=>'12','firstname'=>'John', 'lastname'=>'Doe']; // encrypt $crypt = $ez->encrypt($data); // decrypt $decrypted = $ez->decrypt($crypt); // print the array in a human readable format echo '<pre>' . json_encode($decrypted, JSON_PRETTY_PRINT) . '</pre>';
crypt (216 bytes)
P9P9WtCGQYQu+Isn7uO0HAMx4Cg+NcFKGmB5Abg4vJD00+PQXmEvHBvycapbOLKZOYnHw0L2Omv/61/6NLWJbQKfjQLXlPykGWiTjwGpz1LD0pZTJla8euIbJHhFiu5RByqeF8Dh40I25Nwh3vGBdIbgffqgT8qIkbIqFQrif8BTzFy1mcLa5so/hWcyUx6T9d8Wrw7l7ifIL2MzReS0hA==
Output
{
"user_id": "12",
"firstname": "John",
"lastname": "Doe"
}
URL safe usage
If you want to use it in URLs or as html-input value, you probably dislike characters like /. So just use the URL_SAFE constant, (true and 1, should work too, but stick to the former).
This makes the crypt strings longer. So pick what's best.
::decrypt() can decrypt an url safe crypt without the URL_SAFE parameter, but has to try to decrypt the data first; so give it a break and use it. 😉
// encrypt $crypt = $ez->encrypt($data, URL_SAFE); // decrypt $decrypted = $ez->decrypt($crypt, URL_SAFE);
crypt (288 bytes, 33% bigger)
UDlQOVd0Q0dRWVF1K0lzbjd1TzBIQU14NENnK05jRktHbUI1QWJnNHZKRDAwK1BRWG1FdkhCdnljYXBiT0xLWk9Zbkh3MEwyT212LzYxLzZOTFdKYlFLZmpRTFhsUHlrR1dpVGp3R3B6MUxEMHBaVEpsYThldUliSkhoRml1NVJCeXFlRjhEaDQwSTI1TndoM3ZHQmRJYmdmZnFnVDhxSWtiSXFGUXJpZjhCVHpGeTFtY0xhNXNvL2hXY3lVeDZUOWQ4V3J3N2w3aWZJTDJNelJlUzBoQT09
rasalas/easycrypt 适用场景与选型建议
rasalas/easycrypt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 08 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 rasalas/easycrypt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rasalas/easycrypt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-29