static void Main(string[] args) { string appKey = "asdasdasd"; string appKeyEncrypted = AES_Helper.Encrypt(appKey, "test"); LicenseDataService dataService = new LicenseDataService(); AuthResponse response = new AuthResponse(); AuthRequest authRequest = new AuthRequest(); authRequest = new AuthRequest() { AppKey = AES_Helper.Encrypt(appKey, "test"), OwnersName = "", OwnersNIP = "6422966998", AppName = "Client_test", //Assembly.GetExecutingAssembly().GetName().Name, AppVersion = "1.0" //string.Format("{0}.{1}", Assembly.GetExecutingAssembly().GetName().Version.Major.ToString(), //Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString()) }; //response = dataService.GetAuth(authRequest); byte[] bytes = dataService.DownloadLicense(authRequest); if (bytes != null) { FileStream fs = new FileStream(@"c:\Users\michal.kaszta\Downloads\cert.xml", FileMode.Create); fs.Write(bytes, 0, bytes.Length); fs.Close(); } }
static void Main(string[] args) { AES_Helper helper = new AES_Helper(); string stringToEncrypt = "Ashish"; string key = "eabe9a2d363fccedceb79d22e3c1671c4493ad289a34ff2b9ca18ca29bd46fed"; System.Console.WriteLine(helper.Encrypt(stringToEncrypt, key)); System.Console.ReadLine(); }
public AuthResponse GetAuthorization(AuthRequest request) { AuthResponse response = new AuthResponse(); Licenses license = new Licenses(); int errorCounter = 0; try { license = this._lstLicenses.Where(l => AES_Helper.Decrypt(l.Lic_Key, "test") == AES_Helper.Decrypt(request.AppKey, "test")).FirstOrDefault(); if (license != null) { if (license.Lic_ActivationStatus != 1) { errorCounter += 1; response.Details.Add(string.Format("License hasn't been activated yet. ")); } if (license.Lic_ExpirationDate < DateTime.Today) { errorCounter += 1; response.Details.Add(string.Format("License has expired on {0}. ", license.Lic_ExpirationDate.ToShortDateString())); } if (license.Contractors.Ctr_NIP != request.OwnersNIP) { errorCounter += 1; response.Details.Add(string.Format("Provided NIP number is invalid for this license. ")); } if (license.Apps.App_Acronym != request.AppName) { errorCounter += 1; response.Details.Add(string.Format("The license key is not intended to this application.")); } else { if (license.Apps.App_Version != request.AppVersion) { errorCounter += 1; response.Details.Add(string.Format("The license key is not intended to this version of {0}.", request.AppName)); } } } else { errorCounter += 1; response.Details.Add(string.Format("Provided key is invalid (license not found).")); } if (errorCounter == 0) { response.IsAuthorized = true; response.ExpirationDate = license.Lic_ExpirationDate; response.Details.Add("Authorization successful."); } else { response.IsAuthorized = false; } } catch (Exception ex) { response.Details.Add(string.Format("There was an error getting authorization: {0}", ex.Message)); } return(response); }