public static void generateStaticEVURL(string PhoneNumber) { string baseURL = "http://mi-sbox.dnlsrv.com/msbox/id/OjR4DtTW"; string correlationID = RandomString(16); string timestamp = DateTime.UtcNow.ToString("yyyyMMddHHmmss"); string nonce = GenerateRandomNumbers(5); string redirectURL = ConfigurationManager.AppSettings["BaseUrl"]; string matchObject = "\"match\": {\r\"consumermdn\":\"" + PhoneNumber + "\"\r}"; string data = "correlationid=" + correlationID + "×tamp=" + timestamp + "&nonce=" + nonce + "&match=" + matchObject; string Base64_data = MyCryptoClass.Base64Encode(data); string urlEncode_data = MyCryptoClass.EncodeBase64Url(Base64_data); }
static void Main(string[] args) { Console.WriteLine("********************Encryption Example******************"); string inputText = "{\"authorization\":\"Basic aG9tb2xvZ2FjYW86ZW1wcmVzYTE=\",\"authToken\":\"aG9tb2xvZ2FjYW8gZW1wcmVzYTEgc3RnNURT\"}"; Console.WriteLine("CREDENCIAIS: {0}", inputText + "\n\n\n"); string encryptedText = MyCryptoClass.EncryptText(inputText); Console.WriteLine("CRYPT: {0}", encryptedText + "\n\n\n"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("********************Decryption Example******************"); Console.WriteLine("RAW: {0}", encryptedText + "\n\n\n"); string decryptedText = MyCryptoClass.DecryptText(encryptedText); Console.WriteLine("DECRYPT: {0}", decryptedText + "\n\n\n"); Console.ReadLine(); }
public ActionResult RunConsumerInfoApi(string billingPostalCode, string authKey) { try { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //Create a web request for "www.msn.com". HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("https://api-sbox.dnlsrv.com/cigateway/id/v1/consumerInfo"); myHttpWebRequest.Method = "POST"; //Get the headers associated with the request. WebHeaderCollection myWebHeaderCollection = myHttpWebRequest.Headers; if (!WebHeaderCollection.IsRestricted("Accept")) { myWebHeaderCollection.Add("Accept", "application/json"); } if (!WebHeaderCollection.IsRestricted("Content-Type")) { myWebHeaderCollection.Add("Content-Type", "application/json"); } if (!WebHeaderCollection.IsRestricted("Authorization")) { myWebHeaderCollection.Add("Authorization", "M58Kf103FkYNgFbrrQkl2sSAO6lUBdau"); } if (!WebHeaderCollection.IsRestricted("RequestTime")) { myWebHeaderCollection.Add("RequestTime", ConfigurationManager.AppSettings["RequestTime"]); } using (var streamWriter = new StreamWriter(myHttpWebRequest.GetRequestStream())) { string json = "{ \"merchantId\" : \"02180007169632\", " + "\"authenticationKey\" : \"" + authKey + "\", " + "\"intendedUseCase\" : \"AR\"," + "\"consumerAuth\" : \"" + billingPostalCode + "\"," + "\"consumerAuthType\" : \"PostalCode\"," + "\"correlationId\" : \"" + RandomString(16) + "\"" + " }"; streamWriter.Write(json); streamWriter.Flush(); } var httpResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { string responseText = streamReader.ReadToEnd(); Object _res = new JavaScriptSerializer().Deserialize <RootResultsObject>(responseText); string key = "e6WMHBIw94OJBoaii3+S9Q=="; string cipherSalt = ((DanalJSONApp.Models.RootResultsObject)_res).results.cipherSalt.Trim(); string encryptedData = ((DanalJSONApp.Models.RootResultsObject)_res).results.encryptedData; string decryptedData = MyCryptoClass.AES_decrypt(encryptedData, key, MyCryptoClass.Base64Encode(cipherSalt)); Object consumerInfoObj = new JavaScriptSerializer().Deserialize <DanalJSONApp.Models.ConsumerInfo.RootObject>(decryptedData); return(Json(consumerInfoObj, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json("fail", JsonRequestBehavior.AllowGet)); } }
public ActionResult MatchAndAttributes(string AuthKey, string firstName, string LastName, string email, string streetAddress1, string streetAddress2, string City) { try { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //Create a web request for "www.msn.com". HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("https://api-sbox.dnlsrv.com/cigateway/id/v1/matchandattributes"); myHttpWebRequest.Method = "POST"; //Get the headers associated with the request. WebHeaderCollection myWebHeaderCollection = myHttpWebRequest.Headers; if (!WebHeaderCollection.IsRestricted("Accept")) { myWebHeaderCollection.Add("Accept", "application/json"); } if (!WebHeaderCollection.IsRestricted("Content-Type")) { myWebHeaderCollection.Add("Content-Type", "application/json"); } if (!WebHeaderCollection.IsRestricted("Authorization")) { myWebHeaderCollection.Add("Authorization", "M58Kf103FkYNgFbrrQkl2sSAO6lUBdau"); } if (!WebHeaderCollection.IsRestricted("RequestTime")) { myWebHeaderCollection.Add("RequestTime", ConfigurationManager.AppSettings["RequestTime"]); } string timestamp = DateTime.UtcNow.ToString("yyyyMMddHHmmss"); string consentID = RandomString(22); using (var streamWriter = new StreamWriter(myHttpWebRequest.GetRequestStream())) { string json = "{\r\n \"intendedUseCase\": \"RM\",\r\n \"merchantId\": \"02180007169632\",\r\n \"identity\": {\r\n \"consumerFirstName\": \"" + firstName + "\",\r\n \"consumerLastName\": \"" + LastName + "\",\r\n \"consumerAddress1\": \"" + streetAddress1 + "\",\r\n \"consumerAddress2\": \"\",\r\n \"consumerCity\": \"" + City + "\",\r\n \"consumerState\": \"\",\r\n \"consumerPostalCode\": \"\",\r\n \"consumerEmailAddress\": \"" + email + "\"\r\n },\r\n \"correlationId\": \"" + RandomString(16) + "\",\r\n \"authenticationKey\": \"" + AuthKey + "\",\r\n \"attributeGroups\": \"matchScores,serviceInfo,accountInfo,additionalAccountInfo,deviceInfo,tokenInfo,changeInfo,velocityInfo\",\r\n \"consentId\" : \"" + consentID + "\",\r\n \"consentTimeStamp\":\"" + timestamp + "\"\r\n}"; streamWriter.Write(json); streamWriter.Flush(); } var httpResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { string responseText = streamReader.ReadToEnd(); Object _res = new JavaScriptSerializer().Deserialize <RootResultsObject>(responseText); string key = "e6WMHBIw94OJBoaii3+S9Q=="; string cipherSalt = ((DanalJSONApp.Models.RootResultsObject)_res).results.cipherSalt.Trim(); string encryptedData = ((DanalJSONApp.Models.RootResultsObject)_res).results.encryptedData; string decryptedData = MyCryptoClass.AES_decrypt(encryptedData, key, MyCryptoClass.Base64Encode(cipherSalt)); Object matchScoreObj = new JavaScriptSerializer().Deserialize <DanalJSONApp.Models.MatchResponse.RootResultObject.RootObject>(decryptedData); int firstNameScore = Convert.ToInt32(((DanalJSONApp.Models.MatchResponse.RootResultObject.RootObject)matchScoreObj).attributes.matchScores.firstNameScore); int lastNameScore = Convert.ToInt32(((DanalJSONApp.Models.MatchResponse.RootResultObject.RootObject)matchScoreObj).attributes.matchScores.lastNameScore); if (firstNameScore < 5 && lastNameScore < 5) { return(Json("scorefail", JsonRequestBehavior.AllowGet)); } return(Json("done", JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json("fail", JsonRequestBehavior.AllowGet)); } }