public bool CheckDemoLicense(int days) { MMDB.Core.MMDBEncryption.CypherKey = Passcode; string key = ""; key = MMDB.Core.MMDBEncryption.Encrypt("MMDB LICENSE DEMO LICENSE KEY", true); string DemoLicense = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.ToString().Replace(@"file:///", "").Replace(@"/", @"\")) + @"\"; if (!File.Exists(DemoLicense + @"..\Demo.key") && File.Exists(DemoLicense + @".\Scripts\Demo.key")) { File.Copy(DemoLicense + @".\Scripts\Demo.key", DemoLicense + @"..\Demo.key"); File.Delete(DemoLicense + @".\Scripts\Demo.key"); } DemoLicense += @"..\Demo.key"; if (!File.Exists(DemoLicense)) { return(false); } List <string> lines = new List <string>(); using (StreamReader r = new StreamReader(DemoLicense)) { string line; while ((line = r.ReadLine()) != null) { lines.Add(line); } } if (MMDBEncryption.Decrypt(lines[0], true) == "MMDB LICENSE DEMO LICENSE KEY") { //Delete file and rewrite. File.Delete(DemoLicense); string[] datetime = new string[1]; datetime[0] = MMDB.Core.MMDBEncryption.Encrypt(DateTime.Now.Date.ToString(), true); File.WriteAllLines(DemoLicense, datetime); return(true); } else { //Found file. Read it. string startdate = MMDBEncryption.Decrypt(lines[0], true); DateTime dt = Convert.ToDateTime(startdate).AddDays(days); if (dt > DateTime.Now) { return(true); } return(false); } }
public void SetServer() { if (!Encrypted) { _SMTPUsername = ConfigurationSettings.AppSettings["SMTPUsername"].ToString(); _SMTPPassword = ConfigurationSettings.AppSettings["SMTPPassword"].ToString(); _SMTPServer = ConfigurationSettings.AppSettings["SMTPServer"].ToString(); } else { MMDB.Core.MMDBEncryption.CypherKey = "MMD8S0lution3"; _SMTPUsername = MMDBEncryption.Decrypt(ConfigurationSettings.AppSettings["SMTPUsername"].ToString(), true); _SMTPPassword = MMDBEncryption.Decrypt(ConfigurationSettings.AppSettings["SMTPPassword"].ToString(), true); _SMTPServer = MMDBEncryption.Decrypt(ConfigurationSettings.AppSettings["SMTPServer"].ToString(), true); } }