private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageUtil.ShowTips("请输入认证码!"); } else { try { KeysSet k = new KeysSet(); //Computer c = new Computer(); textBox2.Text = k.EncryptDES(textBox1.Text, "zanglili"); StreamWriter sw = new StreamWriter(Application.StartupPath + "/" + textBox1.Text + "_key.txt"); sw.Write(textBox2.Text); sw.Close(); MessageBox.Show("生成授权文件成功!"); } catch (Exception ex) { MessageUtil.ShowError("错误信息:"+ex.Message); } } }
private void button1_Click(object sender, EventArgs e) { KeysSet k = new KeysSet(); Computer c = new Computer(); string m1 = k.EncryptDES(c.CpuID,"zanglili"); //string m2 = k.EncryptDES(textBox1.Text, "zanglili"); string m2 = textBox1.Text; if (m1 == m2) { FileRead f = new FileRead(); f.WriterData(m1); YZ.ActiveForm.Close(); } else { MessageBox.Show("认证错误,请咨询管理人员"); } }
public void YZ() { Computer c = new Computer(); KeysSet k = new KeysSet(); FileRead f = new FileRead(); string from_key = f.ReadData(); string key = c.CpuID; if (k.EncryptDES(c.CpuID, "zanglili") != from_key) { MessageBox.Show("请验证"); YZ y = new YZ(); y.ShowDialog(); } //String a1 = k.EncryptDES(key, "zanglili"); //MessageBox.Show(a1);//加密后的字符串 //String a2 = k.DecryptDES(a1, "zanglili"); //MessageBox.Show(a2);//解密后的原样字符串 // return i; }