php实现的国密sm3签名,支持php5.6以上的版本
https://github.com/lizhichao/sm
composer require lizhichao/one-sm
<?php
require __DIR__ . '/vendor/autoload.php';
// 字符串签名
echo \OneSm\Sm3::sign('abc') . PHP_EOL;
echo \OneSm\Sm3::sign(str_repeat("adfas哈哈哈", 100)) . PHP_EOL;
// 文件签名
echo \OneSm\Sm3::signFile(__FILE__) . PHP_EOL;
php bench.php
结果
openssl:c4cae8d8730206d130e1eef9de3e00225da0b556cfcb8d0076561352ff19f769
one-sm3:c4cae8d8730206d130e1eef9de3e00225da0b556cfcb8d0076561352ff19f769
SM3-PHP:c4cae8d8730206d130e1eef9de3e00225da0b556cfcb8d0076561352ff19f769
openssl time:4.8391819000244ms
one-sm3 time:5.7239532470703ms
SM3-PHP time:684.2360496521ms