|
|
@@ -43,5 +43,64 @@ namespace MySystem.Areas.Api.Controllers
|
|
|
return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
+
|
|
|
+ #region 活体认证
|
|
|
+ public string initFaceVerify(string value)
|
|
|
+ {
|
|
|
+ function.WriteLog(value, "活体认证提交");
|
|
|
+ value = DesDecrypt(value);
|
|
|
+ JsonData data = JsonMapper.ToObject(value);
|
|
|
+ int targetId = int.Parse(data["targetId"].ToString());
|
|
|
+ string realName = data["realName"].ToString();
|
|
|
+ string idCard = data["idCard"].ToString();
|
|
|
+ string metaInfo = data["metaInfo"].ToString();
|
|
|
+ string accessToken = data["accessToken"].ToString();
|
|
|
+ string jsonString = "{\"targetId\":" + targetId + ",\"realName\":\"" + realName + "\",\"idCard\":\"" + idCard + "\",\"metaInfo\":\"" + metaInfo + "\"}";
|
|
|
+
|
|
|
+ string jsonData = AesEncrypt(jsonString);
|
|
|
+ jsonData = Convert.ToBase64String(Encoding.UTF8.GetBytes(jsonData));
|
|
|
+
|
|
|
+ Dictionary<string, string> header = new Dictionary<string, string>();
|
|
|
+ header.Add("Authorization", "Bearer " + accessToken);
|
|
|
+ string result = function.PostWebRequest(ConfigurationManager.AppSettings["LkbHost"] + "/v1/lkb/mchServer/faceVerify/initFaceVerify", jsonData, header, "application/json");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ public string queryFaceVerify(string value)
|
|
|
+ {
|
|
|
+ function.WriteLog(value, "活体认证查询");
|
|
|
+ value = DesDecrypt(value);
|
|
|
+ JsonData data = JsonMapper.ToObject(value);
|
|
|
+ int targetId = int.Parse(data["targetId"].ToString());
|
|
|
+ string accessToken = data["accessToken"].ToString();
|
|
|
+ string jsonString = "{\"targetId\":" + targetId + "}";
|
|
|
+
|
|
|
+ string jsonData = AesEncrypt(jsonString);
|
|
|
+ jsonData = Convert.ToBase64String(Encoding.UTF8.GetBytes(jsonData));
|
|
|
+
|
|
|
+ Dictionary<string, string> header = new Dictionary<string, string>();
|
|
|
+ header.Add("Authorization", "Bearer " + accessToken);
|
|
|
+ string result = function.GetWebRequest(ConfigurationManager.AppSettings["LkbHost"] + "/v1/lkb/mchServer/faceVerify/query?value=" + jsonData, header);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ public string AesEncrypt(string str)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(str)) return null;
|
|
|
+ Byte[] toEncryptArray = Encoding.UTF8.GetBytes(str);
|
|
|
+ string key = "CBTU1dD4Kd5pyiGWTsI10jRQ3SvKusSV";
|
|
|
+ string iv = "DYgjCEIMVrj2W9xN";
|
|
|
+
|
|
|
+ System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged
|
|
|
+ {
|
|
|
+ Key = Encoding.UTF8.GetBytes(key),
|
|
|
+ IV = Encoding.UTF8.GetBytes(iv),
|
|
|
+ Mode = System.Security.Cryptography.CipherMode.CBC,
|
|
|
+ Padding = System.Security.Cryptography.PaddingMode.PKCS7
|
|
|
+ };
|
|
|
+ System.Security.Cryptography.ICryptoTransform cTransform = rm.CreateEncryptor();
|
|
|
+ Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
|
|
|
+ return Convert.ToBase64String(resultArray, 0, resultArray.Length);
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|