c#写的国密SM2和SM4解密类,可用于腾讯云人脸身份验证

nuget仓库引用依赖Ch.Gmsm

SM2解密

using Ch.Gmsm;

var sm2data = new SM2("私钥的HEX String", SM2Mode.C1C3C2) //SM2Mode根据需求可选C1C2C3和C1C3C2
              .DecryptByBase64String("待解密的base64编码");

// (可选)根据需求转字符串
var sm2Str = Encoding.UTF8.GetString(sm2data);

SM4解密

using Ch.Gmsm;

var sm4data = new SM4(sessionKey)
              .DecryptByBase64String("待解密的base64编码");

// (可选)根据需求转字符串
var sm4Str = Encoding.UTF8.GetString(sm4data);

腾讯人脸识别解密

using Ch.Gmsm;

var sessionKey = new SM2("私钥", SM2Mode.C1C3C2)
              .DecryptByBase64String("DesKey");

var data = new SM4(sessionKey)
              .DecryptByBase64String("UserInfo");

var result = Encoding.UTF8.GetString(data);

猜你喜欢

转载自blog.csdn.net/leonnew/article/details/127085855
今日推荐