/// <summary> /// 注册 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void CreateReg() { string fileName = string.Empty; OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fileName = openFileDialog.FileName; } else { return; } string localFileName = string.Concat ( Environment.CurrentDirectory, Path.DirectorySeparatorChar, RegistFileHelper.ComputerInfofile ); if (fileName != localFileName) { File.Copy(fileName, localFileName, true); } string computer = RegistFileHelper.ReadComputerInfoFile(); EncryptionHelper help = new EncryptionHelper(EncryptionKeyEnum.KeyB); string md5String = help.GetMD5String(computer); string registInfo = help.EncryptString(md5String); RegistFileHelper.WriteRegistFile(registInfo); MessageBox.Show("注册码已生成"); }
public string Fun() { System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; string computer = ComputerInfo.GetComputerInfo(); encryptComputer = new EncryptionHelper().EncryptString(computer); if (CheckRegist() == false) { RegistFileHelper.WriteComputerInfoFile(encryptComputer); return(encryptComputer); } return(null); }
private bool CheckRegistData(string key) { if (RegistFileHelper.ExistRegistInfofile() == false) { isRegist = false; return(false); } else { string info = RegistFileHelper.ReadRegistFile(); var helper = new EncryptionHelper(EncryptionKeyEnum.KeyB); string registData = helper.DecryptString(info); if (key == registData) { isRegist = true; return(true); } else { isRegist = false; return(false); } } }