Exemple #1
0
        /// <summary>
        /// 持卡人信息域customerInfo构造,当勾选对敏感信息加密权限,启用新加密规范(对phoneNo,cvn2,expired加密)适用
        /// </summary>
        /// <param name="customerInfo">Dictionary的customerInfo</param>
        /// <param name="encoding">编码</param>
        /// <returns>string类型结果</returns>
        public static string GetCustomerInfoWithEncrypt(Dictionary <string, string> customerInfo, Encoding encoding)
        {
            if (customerInfo == null || customerInfo.Count == 0)
            {
                return("");
            }
            Dictionary <string, string> encryptedInfo = new Dictionary <string, string>();

            foreach (KeyValuePair <string, string> pair in customerInfo)
            {
                if (pair.Key == "phoneNo" || pair.Key == "cvn2" || pair.Key == "expired")
                {
                    encryptedInfo[pair.Key] = pair.Value;
                }
            }
            customerInfo.Remove("phoneNo");
            customerInfo.Remove("cvn2");
            customerInfo.Remove("expired");
            if (encryptedInfo.Count != 0)
            {
                string encryptedInfoStr = SDKUtil.CreateLinkString(encryptedInfo, false, false);
                encryptedInfoStr = SecurityUtil.EncryptData(encryptedInfoStr, encoding);
                customerInfo["encryptedInfo"] = encryptedInfoStr;
            }
            string customerInfoStr = "{" + SDKUtil.CreateLinkString(customerInfo, false, false) + "}";

            return(Convert.ToBase64String(encoding.GetBytes(customerInfoStr)));
        }
Exemple #2
0
 /// <summary>
 /// 敏感信息加密并做base64(卡号,手机号,cvn2,有效期)
 /// </summary>
 /// <param name="encoder"></param>
 /// <returns></returns>
 public static string EncryptData(string data, Encoding encoding)
 {
     return(SecurityUtil.EncryptData(data, encoding));
 }