luckykellan / dart_sm

基于Dart语言实现的国密SM2、SM3、SM4算法。
Apache License 2.0
34 stars 8 forks source link

SM2 验签的时候这个位置会报错,只是传了个公钥进去 #10

Open stoneUoU opened 5 months ago

stoneUoU commented 5 months ago

image

代码如下: var sortString = "appId=19E179E5DC29C05E65B90CDE57A1C7E5&code=0&data={"accessToken":"!TgbtrMd3RFP_mk8P-qJG985Mjn_9suebPrBPfdyQZM08tqXOqaoq17e6mXqw2w9TKuj-sSvmGpGIih7jzH3FZPXmXDRkwN3SvwxpabD-Bi8TrYy6y_682iI0qtyKUh5PnK0Qw-ZEG3vQjgh0s9SA6zs5F0iWcocpg0NwNiRLKnNvg4geZHg9dMaymZUd8r8he7F51URXrHEORjkbUdwopusw==","certDateFlag":"1","certifyType":"0","isNeedFace":"0","isTrustDev":"1","pwdFlag":"0","refreshToken":"59b50736b38c4331ab8ef3414ea09d2e","secureToken":"aZIFOGqGe/SMPL3bhmvM/C6KbCaxi/pyE/juCpYsRJcgdkF6IMCiCjY7U+SBKMiQCo3Ti7xWwYRZloTE44djUGt+WvBTCcRmi4HoJ1Tb2xuiNFvTNo5nGx1BPBMFpN7JzUzRKBkXORWtUgxCqwjyuzq58SA4o09QvjHrWYp+qM1VWgMkKc53nzALYMI0bS42dvwflEuJbXm5UdANFs/rsc2LrmHqYHH+X46pCcyvC3nea9PPTMxOBT87CScZOmj6eC7Gkjwkeg2a2LSlV2IknWJEYCXeQnNsDsdD2jMbWl9npjDoGgwZlZmsR6OGijqVI3uA9uQBpuIRwbe0MfkJTA=="}&encType=SM4&message=成功&signType=SM2&timestamp=1716195185&type=success&key=D91CEB11EE62219CD91CEB11EE62219C";

var signData = "0d63e83510a7e1df0bb0d5708fc25091d1c8f5e4f3e60d08ad8222ab1121f0f9ffa31768f46b21fddad7d3b141971d26c04c39a4376aecfc79a64cabc97811ad";

var pubkey = "d74188eeb242f52e58da294017c4fb9dc7c8edab0224241d236e037196f77946ce2e4490c46957093c7a59209b58fa40f9076ccc6fef7d5c27ba499b3ab3ec2d";

if (SM2.verifySignature(sortString, signData, pubkey, hash: true, userId: "1234567812345678")) { print("YES"); } else { print("NO"); }