private void Button_Click(object sender, RoutedEventArgs e) { if (name.Text == "" || name.Text == "First Name" || surname.Text == "" || surname.Text == "Last Name" || email.Text == "" || email.Text == "E-mail" || password.Text == "" || password.Text == "Password" || confpassword.Text == "" || confpassword.Text == "Confirm Password") { lbl.Text = "Please complete all fields"; } else if (password.Text != confpassword.Text) { lbl.Text = "Password's do not match"; } else { lbl.Text = "Registration..."; ServiceContainer.Instance.User = new User { FirstName = name.Text, LastName = surname.Text, Password = MD5Core.GetHashString(password.Text), Email = email.Text }; if (Service.RegisterUser(ServiceContainer.Instance.User)) { lbl.Text = "User has been created"; } else { lbl.Text = "Error"; } } }
public static byte[] GetHash(byte[] input) { if (null == input) { throw new System.ArgumentNullException("input", "Unable to calculate hash over null input data"); } //Intitial values defined in RFC 1321 ABCDStruct abcd = new ABCDStruct(); abcd.A = 0x67452301; abcd.B = 0xefcdab89; abcd.C = 0x98badcfe; abcd.D = 0x10325476; //We pass in the input array by block, the final block of data must be handled specialy for padding & length embeding int startIndex = 0; while (startIndex <= input.Length - 64) { MD5Core.GetHashBlock(input, ref abcd, startIndex); startIndex += 64; } // The final data block. return(MD5Core.GetHashFinalBlock(input, startIndex, input.Length - startIndex, abcd, (Int64)input.Length * 8)); }
private void login_Click(object sender, RoutedEventArgs e) { if (Login.Text != "" && Password.Text != "" && Login.Text != "Login" && Password.Text != "Password") { if (ServiceContainer.Instance.User == null) { ServiceContainer.Instance.User = new User(); } ServiceContainer.Instance.User.Email = Login.Text; ServiceContainer.Instance.User.Password = MD5Core.GetHashString(Password.Text); User user = ServiceContainer.Instance.User; try { Service.AuthorizeUser(ref user); } catch (ServiceException m) { Console.WriteLine(m); } } }