经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 程序设计 » ASP.net » 查看文章
使用招商银行云直连服务提现(.Net6)
来源:cnblogs  作者:tuohaibei  时间:2023/3/6 9:15:19  对本文有异议

以下代码的功能是用户可以实现业务中用户虚拟钱包的钱提现到用户银行卡,其实本质上是把商户的账户资金划转到用户银行卡,其实就是银行转账,相关代码如下:

  1. ///此方法存在部分业务代码,核心方法是doProcess方法且基本是可以复用的,其它的代码可以根据自身业务场景灵活处理;
    public
    async Task<WithDrawResultDto> WithDrawToBank(TransferToBankDto transferToBankDto)
  2. {
  3. decimal balance = await _repository.WalletRepository.GetWalletBalance(new Contract.User.UserBasicDto()
  4. {
  5. WeChatId = transferToBankDto.WeChatId,
  6. });
  7. if (balance < transferToBankDto.Amount)
  8. {
  9. return new WithDrawResultDto() { WithDrawResult = false, Message = "可用余额不够,请重新输入提现金额。" };
  10. }
  11. long userId = await _repository.UserRepository.GetUserIdByWeChatId(transferToBankDto.WeChatId);
  12. if (userId == 0)
  13. {
  14. return new WithDrawResultDto() { WithDrawResult = false, Message = "用户不存在" };
  15. }
  16. //bool walletToBankResult = await _walletService.WalletToBankAccount(transferToBankDto.WeChatId, userId, transferToBankDto.Amount, (int)WalletCashType.Withdrawing, yurRef);
  17. //if (walletToBankResult)
  18. //{
  19. Log.Information("begin WithDraw call cloud direct");
  20. string reqId = DCHelper.GetTime() + RandomHelper.GeneratorRandomStr(7);
  21. decimal amount = transferToBankDto.Amount;
  22. string bankCode = await _repository.BankRepository.QueryBankCodeByBankAccount(userId, transferToBankDto.BankAccount);
  23. string bankHolder = await _repository.BankRepository.QueryCardHolder(userId, transferToBankDto.BankAccount);
  24. Log.Information($"bankHolder:{bankHolder}");
  25. //记录业务编号
  26. //业务编号记录到数据库
  27. // 组织发送报文
  28. JObject obj = new JObject();
  29. JObject req = new JObject();
  30. JArray bb1paybmx1BodyArray = new JArray();
  31. JObject bb1paybmx1Body = new JObject();
  32. JObject bb1paybmx1Body2 = new JObject();
  33. JArray bb1payopx1BodyArray = new JArray();
  34. JObject bb1payopx1Body = new JObject();
  35. JObject bb1payopx1Body2 = new JObject();
  36. JObject head = new JObject();
  37. head.Add("funcode", FunCode);// FunCode = "BB1PAYOP";功能代码
  38. head.Add("userid", UID);//用户编号,与商户相关
  39. head.Add("reqid", reqId);
  40. bb1paybmx1Body.Add("busCod", BusCod);//BusCod = "N02030";业务编码
  41. bb1paybmx1Body.Add("busMod", BusMod);///业务模式
  42. bb1paybmx1BodyArray.Add(bb1paybmx1Body);
  43. //bb1paybmx1Body2.Add("bb1paybmx1", bb1paybmx1BodyArray);
  44. JArray bb1payopx1 = new JArray();
  45. bb1payopx1Body.Add("dbtAcc", CompanyCard);//公司账号
  46. bb1payopx1Body.Add("crtAcc", transferToBankDto.BankAccount);//收款人账号
  47. bb1payopx1Body.Add("crtNam", bankHolder);//持卡人姓名
  48. bb1payopx1Body.Add("ccyNbr", CurrencyCode);//币种 CurrencyCode = "10";//10代表人民币
  49. bb1payopx1Body.Add("trsAmt", amount.ToString("#0.00"));
  50. //bb1payopx1Body.Add("crtBnk", "招商银行深圳分行");
  51. bb1payopx1Body.Add("bnkFlg", (bankCode == CMBCode ? "Y" : "N"));//CMBCodeCMBCode = "CMB";如果是招商银行,bnkFlg的取值是Y
  52. bb1payopx1Body.Add("stlChn", StlChn);//StlChn为R代表及时到账
  53. bb1payopx1Body.Add("nusAge", "钱包提现到银行卡");
  54. //bb1payopx1Body.Add("yurRef", "202008260078000033");
  55. bb1payopx1Body.Add("yurRef", yurRef);//业务流水号,可以使用雪花算法生成
  56. bb1payopx1BodyArray.Add(bb1payopx1Body);
  57. JObject jobjectBodyList = new JObject();
  58. jobjectBodyList.Add("bb1paybmx1", bb1paybmx1BodyArray);
  59. jobjectBodyList.Add("bb1payopx1", bb1payopx1BodyArray);
  60. JObject jobjectBody = new JObject();
  61. jobjectBody.Add("body", jobjectBodyList);
  62. jobjectBody.Add("head", head);
  63. JObject requestBody = new JObject();
  64. requestBody.Add("request", jobjectBody);
  65. //bb1payopx1Body2.Add("bb1payopx1", bb1payopx1BodyArray);
  66. // 请求发送接收
  67. var withDrawResult = doProcess(requestBody, FunCode);
  68. if (withDrawResult.WithDrawResult == true)
  69. {
  70. bool walletToBankResult = await _walletService.WalletToBankAccount(transferToBankDto.WeChatId, userId, transferToBankDto.Amount, (int)WalletCashType.Withdrawing, yurRef);
  71. WithDrawToBankRecord withDrawToBankRecord = new WithDrawToBankRecord
  72. (userId: userId, funcode: FunCode, reqid: reqId, busCod: BusCod, busMod: BusMod, dbtAcc: CompanyCard,
  73. crtAcc: transferToBankDto.BankAccount, crtNam: bankHolder, ccyNbr: CurrencyCode,
  74. trsAmt: amount, bnkFlg: (bankCode == CMBCode ? "Y" : "N"), stlChn: StlChn, nusAge: "钱包提现到银行卡", yurRef: yurRef.ToString(), withdrawStatus: 0,openId: transferToBankDto.OpenId);
  75. await _repository.RedPackageRepository.CreateWithDrawToBankRecord(withDrawToBankRecord);
  76. await WithDrawSendMsgToClient.SendMsgToClient(openId: transferToBankDto.OpenId, templageId: SuccessTemplateId, amount: amount, withdrawDatetime: DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), WithdrawToBankStatus.Success);
  77. }
  78. //更新出金时间
  79. await _repository.BankRepository.UpdateWithDrawDateTimeAsync(userId, transferToBankDto.BankAccount);
  80. return withDrawResult;
  81. //}
  82. //else
  83. //{
  84. // return new WithDrawResultDto() { WithDrawResult = false,Message="提现失败,请稍后重试." };
  85. //}
  86. }

DCHelper辅助类

  1. using Newtonsoft.Json.Linq;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Net;
  7. using System.Net.Security;
  8. using System.Security.Cryptography.X509Certificates;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace Demo.Utils
  12. {
  13. public class DCHelper
  14. {
  15. public static string SerialJsonOrdered(JObject json)
  16. {
  17. List<string> keyList = new List<string>();
  18. foreach (var x in json)
  19. {
  20. keyList.Add(x.Key);
  21. }
  22. string[] keyArray = keyList.ToArray();
  23. Array.Sort(keyArray, string.CompareOrdinal);
  24. StringBuilder appender = new StringBuilder();
  25. appender.Append("{");
  26. bool isFirstEle = true;
  27. foreach (var key in keyArray)
  28. {
  29. if (!isFirstEle)
  30. {
  31. appender.Append(",");
  32. }
  33. Object val = json[key];
  34. if (val is JObject)
  35. {
  36. appender.Append("\"").Append(key).Append("\":");
  37. appender.Append(SerialJsonOrdered((JObject)val));
  38. }
  39. else if (val is JArray)
  40. {
  41. JArray jarray = (JArray)val;
  42. appender.Append("\"").Append(key).Append("\":[");
  43. bool isFirstArrEle = true;
  44. for (int i = 0; i < jarray.Count; i++)
  45. {
  46. if (!isFirstArrEle)
  47. {
  48. appender.Append(",");
  49. }
  50. Object obj = jarray[i];
  51. if (obj is JObject)
  52. {
  53. appender.Append(SerialJsonOrdered((JObject)obj));
  54. }
  55. else
  56. {
  57. appender.Append(obj.ToString());
  58. }
  59. isFirstArrEle = false;
  60. }
  61. appender.Append("]");
  62. }
  63. else if (((JToken)val).Type == JTokenType.String)
  64. {
  65. string value = val.ToString();
  66. appender.Append("\"").Append(key).Append("\":").Append("\"").Append(value.Replace("\\", "\\\\")).Append("\"");
  67. }
  68. else if (((JToken)val).Type == JTokenType.Boolean)
  69. {
  70. string value = val.ToString().ToLower();
  71. appender.Append("\"").Append(key).Append("\":").Append(value);
  72. }
  73. else
  74. {
  75. string value = val.ToString();
  76. appender.Append("\"").Append(key).Append("\":").Append(value);
  77. }
  78. isFirstEle = false;
  79. }
  80. appender.Append("}");
  81. return appender.ToString();
  82. }
  83. public static String GetTime()
  84. {
  85. return DateTime.Now.ToString("yyyyMMddHHmmssfff");
  86. }
  87. public static String GetTime2()
  88. {
  89. return DateTime.Now.ToString("yyyyMMddHHmmss");
  90. }
  91. // 发送Post请求
  92. public static String DoPostForm(String httpUrl, Hashtable param)
  93. {
  94. Encoding encoding = Encoding.GetEncoding("utf-8");
  95. HttpWebResponse response = PostHttps(httpUrl, param, encoding);
  96. Stream stream = response.GetResponseStream();
  97. StreamReader sr = new StreamReader(stream);
  98. return sr.ReadToEnd();
  99. }
  100. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  101. {
  102. return true; //信任所有https站点证书,不安全,请勿在生产环境中使用。
  103. }
  104. private static HttpWebResponse PostHttps(string url, Hashtable param, Encoding encoding)
  105. {
  106. HttpWebRequest request = null;
  107. //ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult); // 请勿在生产环境中使用该行程序
  108. request = WebRequest.Create(url) as HttpWebRequest;
  109. request.ProtocolVersion = HttpVersion.Version11;
  110. request.Method = "POST";
  111. request.ContentType = "application/x-www-form-urlencoded";
  112. request.Timeout = 15000;
  113. request.KeepAlive = false;
  114. request.ReadWriteTimeout = 60000;
  115. byte[] data = encoding.GetBytes(CreateLinkString(param));
  116. request.ContentLength = data.Length;
  117. using (Stream stream = request.GetRequestStream())
  118. {
  119. stream.Write(data, 0, data.Length);
  120. }
  121. WebResponse res;
  122. try { res = request.GetResponse(); }
  123. catch (WebException e)
  124. {
  125. res = e.Response;
  126. }
  127. return (HttpWebResponse)res;
  128. }
  129. private static string CreateLinkString(Hashtable param)
  130. {
  131. IEnumerator keys = param.Keys.GetEnumerator();
  132. StringBuilder prestr = new StringBuilder();
  133. int i = 0;
  134. while (keys.MoveNext())
  135. {
  136. i++;
  137. string key = keys.Current as string;
  138. string value = param[key] as string;
  139. if (i == param.Count)
  140. {
  141. prestr.Append(key).Append("=").Append(value);
  142. }
  143. else
  144. {
  145. prestr.Append(key).Append("=").Append(value).Append("&");
  146. }
  147. }
  148. return prestr.ToString();
  149. }
  150. }
  151. }

RandomHelper辅助类

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Demo.Utils
  7. {
  8. public static class RandomHelper
  9. {
  10. public static string GeneratorRandomStr(int len)
  11. {
  12. string chars = "0123456789abcdefghijklmnopqrstuvwxyz";
  13. Random randrom = new Random((int)DateTime.Now.Ticks);
  14. string str = "";
  15. for (int i = 0; i < len; i++)
  16. {
  17. str += chars[randrom.Next(chars.Length)];
  18. }
  19. return str;
  20. }
  21. }
  22. }

 

核心方法:

  1. private WithDrawResultDto doProcess(JObject jObject, string FUNCODE)
  2. {
  3. JObject obj = new JObject();
  4. // 签名
  5. obj.Add("sigdat", "__signature_sigdat__");
  6. obj.Add("sigtim", DCHelper.GetTime2());
  7. jObject.Add("signature", obj);
  8. string source = DCHelper.SerialJsonOrdered(jObject);
  9. Console.WriteLine("签名原文: " + source);
  10. Log.Information($"{FUNCODE} request data is {source}");
  11. Encoding encoding = Encoding.UTF8;
  12. byte[] signature1 = DCCryptor.CMBSM2SignWithSM3(GetID_IV(), Convert.FromBase64String(privkey), encoding.GetBytes(source));//privkey是私钥
  13. string sigdat1 = Convert.ToBase64String(signature1);
  14. Console.WriteLine("签名结果: " + sigdat1);
  15. obj["sigdat"] = sigdat1;
  16. // SM4-CBC加密
  17. string plaintxt = jObject.ToString();
  18. Console.WriteLine("加密前req: " + plaintxt);
  19. byte[] enInput = DCCryptor.CMBSM4EncryptWithCBC(encoding.GetBytes(sm4key), GetID_IV(), encoding.GetBytes(plaintxt));//sm4key是用户的对称密钥
  20. string req = Convert.ToBase64String(enInput);
  21. Console.WriteLine("加密后req: " + req);
  22. Log.Information("begin send request to cloud direct");
  23. // 发送请求
  24. Hashtable map = new Hashtable();
  25. map.Add("UID", UID);
  26. map.Add("ALG", ALG_SM);//ALG_SM = "SM";采用国密算法
  27. map.Add("DATA", HttpUtility.UrlEncode(req, encoding));
  28. map.Add("FUNCODE", FUNCODE);
  29. string res = DCHelper.DoPostForm(URL, map);//访问招商银行的api请求地址:(测试环境:http://cdctest.cmburl.cn/cdcserver/api/v2;正式环境:https://cdc.cmbchina.com/cdcserver/api/v2)
  30. Log.Information("end request");
  31. Console.WriteLine("res: " + res);
  32. Log.Information("DoPostForm {@res}", res);
  33. try
  34. {
  35. Convert.FromBase64String(res);
  36. }
  37. catch (Exception ex)
  38. {
  39. Console.WriteLine("访问返回错误.");
  40. Log.Information(" Convert.FromBase64String error {@ex}", ex);
  41. return new()
  42. {
  43. WithDrawResult = false,
  44. Message = "访问返回错误."
  45. };
  46. }
  47. // 解密请求
  48. string resplain = encoding.GetString(DCCryptor.CMBSM4DecryptWithCBC(encoding.GetBytes(sm4key), GetID_IV(), Convert.FromBase64String(res)));
  49. Console.WriteLine("res decrypt: " + resplain);
  50. Log.Information($"{FUNCODE} response data is {resplain}");
  51. // 验签
  52. JObject object2 = JObject.Parse(resplain);
  53. JObject? object3 = object2["signature"] as JObject;
  54. string? resSign = object3?["sigdat"]?.ToString();
  55. object3["sigdat"] = "__signature_sigdat__";
  56. object2["signature"] = object3;
  57. string resSignSource = DCHelper.SerialJsonOrdered(object2);
  58. Console.WriteLine("验签原文: " + resSignSource);
  59. Console.WriteLine("验签签名值: " + resSign);
  60. bool verify = DCCryptor.CMBSM2VerifyWithSM3(GetID_IV(), Convert.FromBase64String(bankpubkey), encoding.GetBytes(resSignSource), Convert.FromBase64String(resSign));//bankpubkey:银行公钥
  61. Console.WriteLine("验签结果: " + verify);
  62. Log.Information($"验签结果:{verify}");
  63. if (verify)
  64. {
  65. //验签成功以后正常判断
  66. if (object2["response"]?["head"]?["resultcode"] is not null)
  67. {
  68. string? resultCode = object2["response"]?["head"]?["resultcode"]?.ToString();
  69. if (resultCode != "SUC0000")
  70. {
  71. Log.Information($"withdraw hava error,resultmsg is {object2["response"]?["head"]?["resultmsg"]?.ToString()}," +
  72. $"resultcode is {object2["response"]?["head"]?["resultcode"]?.ToString()}");
  73. return new()
  74. {
  75. WithDrawResult = false,
  76. Message = object2["response"]?["head"]?["resultmsg"]?.ToString()
  77. };
  78. }
  79. else
  80. {
  81. string[] errors = new[] { "F", "B", "R", "D", "C" };
  82. string? rtnFlg = object2["response"]?["body"]?["bb1payopz1"][0]?["rtnFlg"]?.ToString();
  83. if (object2["response"]?["body"]?["bb1payopz1"][0]?["reqSts"]?.ToString() == "FIN" && errors.Contains(rtnFlg))
  84. {
  85. Log.Information($"withdraw hava error,errTxt is {object2["response"]?["body"]?["bb1payopz1"][0]?["errTxt"]?.ToString()}," +
  86. $"errCod is {object2["response"]?["body"]?["bb1payopz1"][0]?["errCod"]?.ToString()}");
  87. return new()
  88. {
  89. WithDrawResult = false,
  90. Message = object2["response"]?["body"]?["bb1payopz1"][0]?["errTxt"]?.ToString()
  91. };
  92. }
  93. }
  94. }
  95. }
  96. else
  97. {
  98. Log.Error("验签失败");
  99. return new()
  100. {
  101. WithDrawResult = false,
  102. Message = "验签失败,请联系系统管理员。"
  103. };
  104. }
  105. return new() { WithDrawResult = true };
  106. }

私有方法

  1. private byte[] GetID_IV()
  2. {
  3. String uid = UID; // 请替换为实际的用户UID
  4. String userid = uid + "0000000000000000";
  5. return Encoding.UTF8.GetBytes(userid.Substring(0, 16));
  6. }

 

DCCryptor辅助类

  1. using Org.BouncyCastle.Asn1;
  2. using Org.BouncyCastle.Asn1.X9;
  3. using Org.BouncyCastle.Crypto;
  4. using Org.BouncyCastle.Crypto.Parameters;
  5. using Org.BouncyCastle.Crypto.Signers;
  6. using Org.BouncyCastle.Math;
  7. using Org.BouncyCastle.Math.EC;
  8. using Org.BouncyCastle.Security;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. namespace Demo.Utils
  15. {
  16. public class DCCryptor
  17. {
  18. public static byte[] CMBSM4EncryptWithCBC(byte[] key, byte[] iv, byte[] input)
  19. {
  20. if (key == null || iv == null || input == null)
  21. {
  22. throw new Exception("CMBSM4EncryptWithCBC 非法输入");
  23. }
  24. return CMBSM4Crypt(key, iv, input, true);
  25. }
  26. public static byte[] CMBSM4DecryptWithCBC(byte[] key, byte[] iv, byte[] input)
  27. {
  28. if (key == null || iv == null || input == null)
  29. {
  30. throw new Exception("CMBSM4DecryptWithCBC 非法输入");
  31. }
  32. return CMBSM4Crypt(key, iv, input, false);
  33. }
  34. public static byte[] CMBSM2SignWithSM3(byte[] id, byte[] privkey, byte[] msg)
  35. {
  36. if (privkey == null || msg == null)
  37. {
  38. throw new Exception("CMBSM2SignWithSM3 input error");
  39. }
  40. ECPrivateKeyParameters privateKey = EncodePrivateKey(privkey);
  41. SM2Signer signer = new SM2Signer();
  42. ParametersWithID parameters = new ParametersWithID(privateKey, id);
  43. signer.Init(true, parameters);
  44. signer.BlockUpdate(msg, 0, msg.Length);
  45. return DecodeDERSignature(signer.GenerateSignature());
  46. }
  47. public static bool CMBSM2VerifyWithSM3(byte[] id, byte[] pubkey, byte[] msg, byte[] signature)
  48. {
  49. if (pubkey == null || msg == null || signature == null)
  50. {
  51. throw new Exception("CMBSM2VerifyWithSM3 input error");
  52. }
  53. ECPublicKeyParameters publicKey = EncodePublicKey(pubkey);
  54. SM2Signer signer = new SM2Signer();
  55. ParametersWithID parameters = new ParametersWithID(publicKey, id);
  56. signer.Init(false, parameters);
  57. signer.BlockUpdate(msg, 0, msg.Length);
  58. return signer.VerifySignature(EncodeDERSignature(signature));
  59. }
  60. private static byte[] CMBSM4Crypt(byte[] keyBytes, byte[] iv, byte[] input, bool forEncrypt)
  61. {
  62. KeyParameter key = ParameterUtilities.CreateKeyParameter("SM4", keyBytes);
  63. ParametersWithIV ivParameterSpec = new ParametersWithIV(key, iv);
  64. IBufferedCipher cipher = CipherUtilities.GetCipher("SM4/CBC/PKCS7Padding");
  65. cipher.Init(forEncrypt, ivParameterSpec);
  66. return cipher.DoFinal(input);
  67. }
  68. private static ECPrivateKeyParameters EncodePrivateKey(byte[] value)
  69. {
  70. BigInteger d = new BigInteger(1, value);
  71. X9ECParameters spec = ECNamedCurveTable.GetByName("sm2p256v1");
  72. ECDomainParameters ecParameters = new ECDomainParameters(spec.Curve, spec.G, spec.N, spec.H, spec.GetSeed());
  73. return new ECPrivateKeyParameters(d, ecParameters);
  74. }
  75. public static ECPublicKeyParameters EncodePublicKey(byte[] value)
  76. {
  77. byte[] x = new byte[32];
  78. byte[] y = new byte[32];
  79. Array.Copy(value, 1, x, 0, 32);
  80. Array.Copy(value, 33, y, 0, 32);
  81. BigInteger X = new BigInteger(1, x);
  82. BigInteger Y = new BigInteger(1, y);
  83. X9ECParameters spec = ECNamedCurveTable.GetByName("sm2p256v1");
  84. ECPoint Q = spec.Curve.CreatePoint(X, Y);
  85. ECDomainParameters ecParameters = new ECDomainParameters(spec.Curve, spec.G, spec.N, spec.H, spec.GetSeed());
  86. return new ECPublicKeyParameters(Q, ecParameters);
  87. }
  88. private static byte[] DecodeDERSignature(byte[] signature)
  89. {
  90. Asn1InputStream stream = new Asn1InputStream(signature);
  91. Asn1Sequence primitive = (Asn1Sequence)stream.ReadObject();
  92. System.Collections.IEnumerator enumeration = primitive.GetEnumerator();
  93. enumeration.MoveNext();
  94. BigInteger R = ((DerInteger)enumeration.Current).Value;
  95. enumeration.MoveNext();
  96. BigInteger S = ((DerInteger)enumeration.Current).Value;
  97. byte[] bytes = new byte[64];
  98. byte[] r = Format(R.ToByteArray());
  99. byte[] s = Format(S.ToByteArray());
  100. Array.Copy(r, 0, bytes, 0, 32);
  101. Array.Copy(s, 0, bytes, 32, 32);
  102. return bytes;
  103. }
  104. private static byte[] EncodeDERSignature(byte[] signature)
  105. {
  106. byte[] r = new byte[32];
  107. byte[] s = new byte[32];
  108. Array.Copy(signature, 0, r, 0, 32);
  109. Array.Copy(signature, 32, s, 0, 32);
  110. Asn1EncodableVector vector = new Asn1EncodableVector();
  111. vector.Add(new DerInteger(new BigInteger(1, r)));
  112. vector.Add(new DerInteger(new BigInteger(1, s)));
  113. return (new DerSequence(vector)).GetEncoded();
  114. }
  115. private static byte[] Format(byte[] value)
  116. {
  117. if (value.Length == 32)
  118. {
  119. return value;
  120. }
  121. else
  122. {
  123. byte[] bytes = new byte[32];
  124. if (value.Length > 32)
  125. {
  126. Array.Copy(value, value.Length - 32, bytes, 0, 32);
  127. }
  128. else
  129. {
  130. Array.Copy(value, 0, bytes, 32 - value.Length, value.Length);
  131. }
  132. return bytes;
  133. }
  134. }
  135. }
  136. }

 

原文链接:https://www.cnblogs.com/cby-love/p/17179462.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号