composer require lpilp/guomi
请确保你升级到
composer 2
及以上版本。PHP >=7.2
,打开gmp组件支持。
如需要使用php5.6 请使用wzhih童鞋fork修改的 https://github.com/wzhih/guomi ;
composer require wzhih/guomi
或是使用该项目的简化版本 https://github.com/lpilp/simplesm2
# 公钥文件查看明文
openssl ec -pubin -in sm2pub.pem -text -noout
#私钥文件查看明文
openssl ec -in sm2.pem -text -noout
function __construct($formatSign='hex', $randFixed = true) {
// 注意: 这个randFixed尽量取false, 如需要固定,请重新生成$foreignkey密码对
$this->adapter = RtEccFactory::getAdapter();
$this->generator = RtEccFactory::getSmCurves()->generatorSm2();
if(in_array($formatSign,$this->arrFormat)){
$this->formatSign = $formatSign;
} else {
$this->formatSign = 'hex';
}
if(!$randFixed){
$this->useDerandomizedSignatures = false;
$this->useDerandomizedEncrypt = false;
}
}
有话要说