public static string GetProductKey(int id) { ProductKey productKey = new ProductKey(); var product = productKey.Single(where : "Id = @0", args: id); return(Security.Decrypt(product.Key, User.GetPassword())); }
private void Import_Click(object sender, EventArgs e) { bool continueImport = true; if (!User.UserCheck()) { Password password = new Password { IsLogin = false }; continueImport = (password.ShowDialog() == System.Windows.Forms.DialogResult.OK); } if (continueImport) { if (OpenFile.ShowDialog() != DialogResult.Cancel) { ImportKeyFile.Import(OpenFile.FileName, User.GetPassword()); LoadProducts(); } } }
private void Ok_Click(object sender, EventArgs e) { if (!IsLogin) { User.SetPassword(passwordText.Text); this.DialogResult = System.Windows.Forms.DialogResult.OK; } if (IsLogin) { if (Security.VerifyHash(passwordText.Text, Security.HashAlgorithm.SHA384, User.GetPassword())) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { this.DialogResult = System.Windows.Forms.DialogResult.No; } } }