Private voidButton1_Click (Objectsender, RoutedEventArgs e) { stringPwdregex ="^[a-za-z0-9]{6,12}$"; System.Text.RegularExpressions.Regex regpwd=NewSystem.Text.RegularExpressions.Regex (Pwdregex); if(!Regpwd.ismatch (PasswordBox1.Password.Trim ())) {label_warning. Content="Hint: the password is made up of 6-12 digits or letters! "; } Else if(PasswordBox1.Password.Equals (Passwordbox2.password)) {MD5 MD5=NewSystem.Security.Cryptography.MD5CryptoServiceProvider (); byte[] str =Md5.computehash (System.Text.Encoding.UTF8.GetBytes (Passwordbox1.password)); stringPWD =string. Empty; for(inti =0; I < Str. Length; i++) {pwd+ = Convert.ToString (Str[i], -). PadLeft (2,'0'); } Try { using(Stockmanagedatacontext Smdatacontext =NewStockmanagedatacontext ()) { stringUsrname = ( This. Parent asLoginwindow). User; vars = smDataContext.Users.Single (c = C.username = =usrname); S.password=pwd; Smdatacontext.submitchanges (); MessageBox.Show ("Password added successfully! "); This. Navigationservice.navigate (NewUri ("Loginpage.xaml", urikind.relative)); } } Catch(Exception ex) {MessageBox.Show (ex). Message); Label_warning. Content="Hint: password modification failed! "; } } Else{label_warning. Content="Hint: the password entered two times is different! "; } }
Password consists of 6-12 digits or letters, password hash encryption