public static Tuple <bool, string> CheckLicense() { string errInfo = "Cannot find the license file."; DirectoryInfo hdDir = new DirectoryInfo("."); foreach (FileInfo found in hdDir.GetFiles("*.lic")) { string encrypted = File.ReadAllText(found.FullName); if (encrypted == string.Empty) { continue; } string plainText = AesTools.Decrypt(encrypted); string[] info = plainText.Split(' '); if (!SystemTools.CheckMAC(info[0])) { errInfo = "The physical address does not match."; continue; } DateTime dt = Convert.ToDateTime(info[1]); if (DateTime.Compare(dt, DateTime.Now) < 0) { errInfo = "Your license is expired."; continue; } return(Tuple.Create(true, Path.GetFileNameWithoutExtension(found.Name))); } return(Tuple.Create(false, errInfo)); }
private void button_Generate_MouseClick(object sender, MouseEventArgs e) { string info = textBox_MAC.Text + " " + dateTimePicker_Expired.Text; string encryptedInfo = AesTools.Encrypt(info); File.WriteAllText(textBox_username.Text + ".lic", encryptedInfo); Process.Start("."); }