wekisen/php-ecrecover
Composer 安装命令:
composer require wekisen/php-ecrecover
包简介
PHP ECRecover Example
关键字:
README 文档
README
This project is showing you how to sign from client-side(browser, javascript) and verify from server-side(php).
Check out this repo to see JS Signature Example: https://github.com/danfinlay/js-eth-personal-sign-examples
eth_sign & verify
- JS Sign
var msg = '0xca5e3f850877ea106134e2a2c8d7c0018a9d412b59abe623b2d1a432f0d163a8' var from = web3.eth.accounts[0] web3.eth.sign(from, msg, function (err, result) { if (err) return console.error(err) console.log('SIGNED:' + result) })
- PHP Verify
$hex = '0xca5e3f850877ea106134e2a2c8d7c0018a9d412b59abe623b2d1a432f0d163a8'; $signed = '0x7b87a3c4dd63bee43d4c880391bb0aaaf210c12356406152a30edc424b9c4de62cc64a266b6faf22691a36489651f1cbf7dee1f028ba24b7d48e5552eac4c93f1b'; echo ecRecover($hex, $signed), "\n";
personal_sign
- JS Sign
var text = 'Hello!!'; var msg = ethUtil.bufferToHex(new Buffer(text, 'utf8')) var from = web3.eth.accounts[0] var params = [msg, from] var method = 'personal_sign' web3.currentProvider.sendAsync({ method, params, from, }, function (err, result) { if (err) return console.error(err) if (result.error) return console.error(result.error) console.log('PERSONAL SIGNED:' + JSON.stringify(result.result)) });
- PHP Verify
$msg = 'Hello!!'; $signed = '0x7b87a3c4dd63bee43d4c880391bb0aaaf210c12356406152a30edc424b9c4de62cc64a266b6faf22691a36489651f1cbf7dee1f028ba24b7d48e5552eac4c93f1b'; echo personal_ecRecover($msg, $signed), "\n";
sign typed data
- JS Sign
const msgParams = [ { type: 'string', name: 'Message', value: 'Hi, Alice!' }, { type: 'uint32', name: 'A number', value: '1337' } ] var from = web3.eth.accounts[0] var params = [msgParams, from] var method = 'eth_signTypedData' web3.currentProvider.sendAsync({ method, params, from, }, function (err, result) { if (err) return console.dir(err) if (result.error) { alert(result.error.message) } if (result.error) return console.error(result) console.log('PERSONAL SIGNED:' + JSON.stringify(result.result)) }
- PHP Verify
$presha_str = hex2bin(substr(keccak256('string Messageuint32 A number'), 2) . substr(keccak256('Hi, Alice!'. pack('N', 1337)), 2)); $hex = keccak256($presha_str); $signed = '0x5147f94643843d709bf7c374fb8d619b27da739413f7ab8de5c788a6b7d2d10e53c4789d8a0398dee6c9f6cb69e094fa801cc00fa4d19f3b71b03a7a4b7cfee11c'; echo ecRecover($hex, $signed), "\n";
References
wekisen/php-ecrecover 适用场景与选型建议
wekisen/php-ecrecover 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.69k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「ecrecover」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wekisen/php-ecrecover 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wekisen/php-ecrecover 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wekisen/php-ecrecover 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
统计信息
- 总下载量: 7.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-26