web3p/rlp
Composer 安装命令:
composer require web3p/rlp
包简介
Recursive Length Prefix Encoding in PHP.
README 文档
README
Recursive Length Prefix Encoding in PHP.
Install
Set minimum stability to dev
composer require web3p/rlp
Usage
RLP encode:
use Web3p\RLP\RLP; $rlp = new RLP; // c483646f67 $encoded = $rlp->encode(['dog']); // 83646f67 $encoded = $rlp->encode('dog');
RLP decode:
use Web3p\RLP\RLP; use Web3p\RLP\Types\Str; $rlp = new RLP; $encoded = $rlp->encode(['dog']); // only accept 0x prefixed hex string $decoded = $rlp->decode('0x' . $encoded); // show 646f67 echo $decoded[0]; // show dog echo hex2bin($decoded[0]); // or you can echo Str::decodeHex($decoded[0]);
API
Web3p\RLP\RLP
encode
Returns recursive length prefix encoding of given inputs.
encode(mixed $inputs)
Mixed inputs - array of string, integer or numeric string.
Note: output is not zero prefixed.
Example
- Encode array of string.
use Web3p\RLP\RLP; $rlp = new RLP; $encoded = $rlp->encode(['web3p', 'ethereum', 'solidity']);
decode
Returns array recursive length prefix decoding of given data.
decode(string $input)
String input - recursive length prefix encoded string.
Note: output is not zero prefixed.
Example
- Decode recursive length prefix encoded string.
use Web3p\RLP\RLP; use Web3p\RLP\Types\Str; $rlp = new RLP; $encoded = $rlp->encode(['web3p', 'ethereum', 'solidity']); $decoded = $rlp->decode('0x' . $encoded); // echo web3p echo hex2bin($decoded[0]); // echo ethereum echo hex2bin($decoded[1]); // echo solidity echo hex2bin($decoded[2]); // or you can echo Str::decodeHex($decoded[0]); echo Str::decodeHex($decoded[1]); echo Str::decodeHex($decoded[2]);
License
MIT
web3p/rlp 适用场景与选型建议
web3p/rlp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 544.21k 次下载、GitHub Stars 达 28, 最近一次更新时间为 2018 年 02 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 web3p/rlp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 web3p/rlp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 544.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 30
- 点击次数: 25
- 依赖项目数: 22
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-01