JuneAndGreen / sm-crypto

国密算法js版
MIT License
894 stars 245 forks source link

sm3-hmac算出来和openssl算的结果不一样 #91

Closed ww2000e closed 11 months ago

ww2000e commented 11 months ago

新版本openssl已经内置国密 echo -n "abcdefg" | openssl dgst -sm3 -hmac "aaaabbbbccccdddd" 出来结果和 hashData = sm3('abcdefg', { │············· key: 'aaaabbbbccccdddd', // 要求为 16 进制串或字节数组
}) 算出来结果不一样

JuneAndGreen commented 11 months ago

看你的例子,确定 openssl 中传入的 key 是当做 16 进制串处理的么?

ww2000e commented 11 months ago

是key传错了,转成61616161626262626363636364646464就行了