private void login_button_Click(object sender, EventArgs e) { //TDES ttt = new TDES(); //ttt.InitTDES("12312134123testdfafasafasfasff"); //string str = ttt.Encrypt(email_textBox.Text); //ttt.InitTDES("0989870987dfskd;lfkslk;;lk/.df"); //string str1 = ttt.Decrypt(str); //MessageBox.Show(str); //MessageBox.Show(str1); string hash_output = HashingSHA.Hash(pswd_textBox.Text); // divide into two keys string key1 = hash_output.Substring(0, hash_output.Length / 2); //MessageBox.Show(key1); string key2 = hash_output.Substring(hash_output.Length / 2, hash_output.Length / 2); //MessageBox.Show(key2); Controller.GetInstance().initEncryptors(key1, key2); if (Controller.GetInstance().SignIn(email_textBox.Text)) { Main_Window mainWind = new Main_Window(); mainWind.Show(); this.Hide(); } else { MessageBox.Show("Please Check Your Email and Password"); } }
public bool SignUp(string userName) { try { UserName = userName; string fileName = userName + ".pswds"; if (File.Exists(fileName)) { return(false); } using (StreamWriter writer = new StreamWriter(fileName)) { string userNameHash = HashingSHA.Hash(userName); userData = new UserData(); userData.UserNameHashed = userNameHash; writer.Write(fileEncryptor.Encrypt(userData.ToString())); writer.Close(); return(SignIn(userName)); } } catch (Exception ioexc) { Console.Write("Error reading the file"); } return(false); }
private void encrypt_button_Click(object sender, EventArgs e) { string hash_output = HashingSHA.Hash(pswd_textBox.Text); // divide into two keys string key1 = hash_output.Substring(0, hash_output.Length / 2); //MessageBox.Show(key1); string key2 = hash_output.Substring(hash_output.Length / 2, hash_output.Length / 2); //MessageBox.Show(key2); Controller.GetInstance().initEncryptors(key1, key2); if (Controller.GetInstance().SignUp(email_textBox.Text)) { Main_Window mainWind = new Main_Window(); mainWind.Show(); this.Close(); } else { MessageBox.Show("Please Check Your Email and Password"); } }
public bool SignIn(string userName) { try { UserName = userName; using (StreamReader reader = new StreamReader(userName + ".pswds")) { string xml = reader.ReadToEnd(); userData = UserData.LoadFromXMLString(fileEncryptor.Decrypt(xml)); if (HashingSHA.Hash(userName) == userData.UserNameHashed) { return(true); } reader.Close(); } } catch (Exception ioexc) { Console.Write("Error reading the file"); } return(false); }