收藏
回答

微信支付:商家转账到零钱中发起转账接口,收款用户姓名在C#.Net 怎么实现加密和获取微信的公钥?

 

//证书路径 商户号 加密
 X509Certificate2 cert = new X509Certificate2(@"D:\web\junjunmei\rest\apiclient_cert.p12", PayConfig.MchId, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
 var privateKey = cert.PrivateKey.ToXmlString(true);
 var certSerialNo = cert.SerialNumber;
 using (RSACryptoServiceProvider sha256 = new RSACryptoServiceProvider())
 {
     byte[] dataInBytes = Encoding.UTF8.GetBytes(message);
     sha256.FromXmlString(privateKey);
     byte[] inArray = sha256.SignData(dataInBytes, CryptoConfig.MapNameToOID("SHA256"));
     string sign = Convert.ToBase64String(inArray);
     return sign;
 }
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容