void RuleSetOnValidationCompleted(object sender, ValidationCompletedEventArgs args) { Validator.RuleSet.ValidationCompleted -= RuleSetOnValidationCompleted; var ruleSetValidationResult = new RuleSetValidationResult(); var validationException = args.Exception; if (validationException != null) { ruleSetValidationResult = validationException.Result; } foreach (var modelMemberPasswordScore in _modelMemberPasswordScores) { var password = View.ObjectTypeInfo.FindMember(modelMemberPasswordScore.Name).GetValue(View.CurrentObject); var passwordScore = PasswordAdvisor.CheckStrength(password + ""); if (passwordScore < modelMemberPasswordScore.PasswordScore) { var messageTemplate = String.Format(CaptionHelper.GetLocalizedText(XpandValidationModule.XpandValidation, "PasswordScoreFailed"), modelMemberPasswordScore.Name, passwordScore, modelMemberPasswordScore.PasswordScore); var validationResult = Validator.RuleSet.NewRuleSetValidationMessageResult(ObjectSpace, messageTemplate, ContextIdentifier.Save, View.CurrentObject, View.ObjectTypeInfo.Type); ruleSetValidationResult.AddResult(validationResult.Results.First()); args.Handled = true; } } if (args.Handled) { throw validationException ?? new ValidationException(ruleSetValidationResult); } }
private void Pwdbox_PasswordChanged(object sender, RoutedEventArgs e) { Password = pwdbox.Password; var re = PasswordAdvisor.GetPasswordStrength(Password); probar.Value = (int)re; switch (re) { default: case PasswordStrength.Blank: break; case PasswordStrength.VeryWeak: probar.Foreground = new SolidColorBrush(Windows.UI.Colors.Red); break; case PasswordStrength.Weak: probar.Foreground = new SolidColorBrush(Windows.UI.Colors.OrangeRed); break; case PasswordStrength.Medium: probar.Foreground = new SolidColorBrush(Windows.UI.Colors.Yellow); break; case PasswordStrength.Strong: probar.Foreground = new SolidColorBrush(Windows.UI.Colors.YellowGreen); break; case PasswordStrength.VeryStrong: probar.Foreground = new SolidColorBrush(Windows.UI.Colors.Green); break; } }
void Handle_TextChanged(object sender, TextChangedEventArgs e) { var strength = PasswordAdvisor.CheckStrength(e.NewTextValue); var strengthName = Enum.GetName(typeof(PasswordScore), strength); VisualStateManager.GoToState(this.StrengthIndicator, strengthName); }
public char PasswordCheck(string text, int charIndex, char addedChar) { if (inputField.text.Length + addedChar > 2) { string password = inputField.text + addedChar; PasswordScore passwordStrengthScore = PasswordAdvisor.CheckStrength(password); // Debug.Log(passwordStrengthScore + ": " + inputField.text + addedChar); switch (passwordStrengthScore) { case PasswordScore.Blank: case PasswordScore.VeryWeak: case PasswordScore.Weak: // Debug.Log("weak password"); passwordStrength.text = "weak password"; passwordStrength.color = new Color(255.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f); break; case PasswordScore.Medium: case PasswordScore.Strong: case PasswordScore.VeryStrong: // Debug.Log("strong password"); passwordStrength.text = "strong password"; passwordStrength.color = new Color(0.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f); break; } } return(addedChar); }
private void Password_TextChanged(object sender, TextChangedEventArgs e) { string pass_strong = ""; switch (PasswordAdvisor.CheckStrength(Password.Text)) { case PasswordScore.Blank: pass_strong = "Blank"; break; case PasswordScore.VeryWeak: pass_strong = "Very Weak"; break; case PasswordScore.Weak: pass_strong = "Weak"; break; case PasswordScore.Medium: pass_strong = "Medium"; break; case PasswordScore.Strong: pass_strong = "Strong"; break; case PasswordScore.VeryStrong: pass_strong = "Very Strong"; break; } pass_st_lbl.Text = "Password strong: " + pass_strong; }
private void textBoxPassWord_TextChanged(object sender, EventArgs e) { labelPassWordE.ForeColor = Color.Red; labelPassWordE.Visible = false; if (textBoxPassWord.Text.Length > 4) { PasswordScore passwordStrengthScore = PasswordAdvisor.CheckStrength(textBoxPassWord.Text); switch (passwordStrengthScore) { case PasswordScore.Blank: labelPassWordE.ForeColor = Color.Red; labelPassWordE.Text = "Blank Password."; labelPassWordE.Visible = true; break; case PasswordScore.VeryWeak: labelPassWordE.ForeColor = Color.Red; labelPassWordE.Text = "Very Weak Password."; labelPassWordE.Visible = true; break; case PasswordScore.Weak: labelPassWordE.ForeColor = Color.DarkOrange; labelPassWordE.Text = "Weak Password."; labelPassWordE.Visible = true; passWordOK = true; break; case PasswordScore.Medium: labelPassWordE.ForeColor = Color.LimeGreen; labelPassWordE.Text = "Medium Password."; labelPassWordE.Visible = true; passWordOK = true; break; case PasswordScore.Strong: labelPassWordE.ForeColor = Color.Green; labelPassWordE.Text = "Strong Password."; labelPassWordE.Visible = true; passWordOK = true; break; case PasswordScore.VeryStrong: labelPassWordE.ForeColor = Color.Green; labelPassWordE.Text = "Very Strong Password."; labelPassWordE.Visible = true; passWordOK = true; break; } } else { labelPassWordE.ForeColor = Color.Red; labelPassWordE.Text = "Password must be more than 4 characters."; labelPassWordE.Visible = true; } }
static void Main(string[] args) { var strength = PasswordAdvisor.CheckStrength("PaSSwordGab43434.@@$$###r.12$"); for (var i = 1; i < 100; i++) { _log.Error("console test log " + i); } }
public SignUpViewModel(TextBox tbUsername, PasswordBox pbPassword) { RegistrationCommand = new RelayCommand(e => { RegistrationPage registrationPage = new RegistrationPage(); SignUpPage.NavigationService.Navigate(registrationPage); }); LogInCommand = new RelayCommand(e => { UserDBContext = new UserDBContext(); UserRepo = new UserRepository <User>(UserDBContext); try { if (UserRepo.FindUser().FirstOrDefault(c => (c.Login == tbUsername.Text && c.Password == pbPassword.Password)).IsVerified == true) { Window win = (Window)SignUpPage.Parent; win.Close(); Mainvm.CurrentUser = UserRepo.FindUser().FirstOrDefault(c => (c.Login == tbUsername.Text && c.Password == pbPassword.Password)); MainWindow.DataContext = Mainvm; MainWindow.ShowDialog(); } } catch (Exception) { MessageBox.Show("Cant find", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }, ckPass => { string password = pbPassword.Password; PasswordScore passwordStrengthScore = PasswordAdvisor.CheckStrength(password); switch (passwordStrengthScore) { case PasswordScore.Blank: case PasswordScore.VeryWeak: return(false); case PasswordScore.Weak: case PasswordScore.Medium: case PasswordScore.Strong: case PasswordScore.VeryStrong: return(true); } return(false); }); }
public void PasswordStrengthCheck() { if (inputField.text.Length >= 0) { string password = inputField.text; PasswordScore passwordStrengthScore = PasswordAdvisor.CheckStrength(password); // Debug.Log(passwordStrengthScore + ": " + inputField.text); switch (passwordStrengthScore) { case PasswordScore.Blank: passwordStrength.text = "Try a combination of factors, or increasing length"; passwordStrength.color = new Color(0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f); break; case PasswordScore.VeryWeak: // Debug.Log("Very weak password"); passwordStrength.text = "Weaker password"; passwordStrength.color = new Color(255.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f); break; case PasswordScore.Weak: // Debug.Log("weak password"); passwordStrength.text = "Weak password"; passwordStrength.color = new Color(255.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f); break; case PasswordScore.Medium: // Debug.Log("Medium password"); passwordStrength.text = "Medium password"; passwordStrength.color = new Color(120.0f / 255.0f, 120.0f / 255.0f, 0.0f / 255.0f); break; case PasswordScore.Strong: // Debug.Log("Strong password"); passwordStrength.text = "Strong password"; passwordStrength.color = new Color(0.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f); break; case PasswordScore.VeryStrong: // Debug.Log("strong password"); passwordStrength.text = "Stronger password"; passwordStrength.color = new Color(21.0f / 255.0f, 181.0f / 255.0f, 109.0f / 255.0f); break; case PasswordScore.Secure: passwordStrength.text = "Long passwords should be your first concern, if nothing else"; passwordStrength.color = new Color(21.0f / 255.0f, 181.0f / 255.0f, 109.0f / 255.0f); break; } } }
public string checkStrength(string password) { string result = ""; int[] passwordStrengthScore = PasswordAdvisor.CheckStrength(password); bool strongEnough = false; for (int i = 0; i < passwordStrengthScore.Length; i++) { if (passwordStrengthScore[i] != 1) { strongEnough = true; } } if (strongEnough) { return("Great password!"); } if (passwordStrengthScore[0] != 1) { result += "Password cannot be blank\n"; } if (passwordStrengthScore[1] != 1) { result += "Password must be longer than 8 characters\n"; } if (passwordStrengthScore[2] != 1) { result += "Password must contain digits\n"; } if (passwordStrengthScore[3] != 1) { result += "Password must contain uppercase and lowercase letters\n"; } if (passwordStrengthScore[3] != 1) { result += "Password must contain special character(s)\n"; } return(result); }
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) { var passwordStrengthScore = PasswordAdvisor.CheckStrength(PasswordBox.Password); switch (passwordStrengthScore) { case PasswordScore.Blank: PasswordHelpLabel.Content = "Blank"; RegisterButton.IsEnabled = false; break; case PasswordScore.VeryWeak: PasswordHelpLabel.Content = "Very Weak"; RegisterButton.IsEnabled = false; break; case PasswordScore.Weak: PasswordHelpLabel.Content = "Weak"; RegisterButton.IsEnabled = false; break; case PasswordScore.Medium: PasswordHelpLabel.Content = "Almost Strong"; RegisterButton.IsEnabled = false; break; case PasswordScore.Strong: PasswordHelpLabel.Content = "Strong"; RegisterButton.IsEnabled = true; break; case PasswordScore.VeryStrong: PasswordHelpLabel.Content = "Very Strong"; RegisterButton.IsEnabled = true; break; } }
/// <summary> /// Find any exposed personal information /// </summary> /// <param name="oSession"></param> /// <param name="bodyAsString"></param> /// <returns>List<PersonalInformation> List of PersonalInformation</returns> private static List <PersonalInformation> FindExposedPersonalInformation(Session oSession, string bodyAsString) { List <PersonalInformation> personalInformationList = new List <PersonalInformation>(); // check if contains personal information P.I if (bodyAsString != "") { MatchCollection mc = Regex.Matches(bodyAsString, "password\":\"([^\"]+)"); foreach (Match m in mc) { Console.WriteLine(m); string passwordValue = m.Groups[1].Value; bool isEncrypted = PasswordAdvisor.IsEncrypted(passwordValue); // if not encrypted, password may be plain text so that we highlight the session if (!isEncrypted) { PersonalInformation personalInformation = new PersonalInformation("password", passwordValue); personalInformationList.Add(personalInformation); } } } return(personalInformationList); }
private void txtPassword_Leave(object sender, EventArgs e) { if (txtPassword.Text == String.Empty) { txtPassword.Text = sysMessages.msgEnterPassword; txtPassword.SelectAll(); txtPassword.Focus(); } string pw = txtPassword.Text; PasswordScore pScore = PasswordAdvisor.CheckStrength(pw); switch (pScore) { case PasswordScore.Blank: { txtStrength.BackColor = Color.Red; txtStrength.ForeColor = Color.White; txtStrength.Text = sysMessages.msgBlank; break; } case PasswordScore.VeryWeak: { txtStrength.BackColor = Color.Orange; txtStrength.ForeColor = Color.White; txtStrength.Text = sysMessages.msgVeryWeak; break; } case PasswordScore.Weak: { txtStrength.BackColor = Color.Yellow; txtStrength.ForeColor = Color.Black; txtStrength.Text = sysMessages.msgWeak; break; } case PasswordScore.Medium: { txtStrength.BackColor = Color.Green; txtStrength.ForeColor = Color.White; txtStrength.Text = sysMessages.msgMedium; break; } case PasswordScore.Strong: { txtStrength.BackColor = Color.SkyBlue; txtStrength.ForeColor = Color.Black; txtStrength.Text = sysMessages.msgStrong; break; } case PasswordScore.VeryStrong: { txtStrength.BackColor = Color.Blue; txtStrength.ForeColor = Color.White; txtStrength.Text = sysMessages.msgVeryStrong; break; } } }
public void CheckStrength_Medium_ReturnsWeak() { var result = PasswordAdvisor.CheckStrength("Abcd1!"); Assert.AreEqual(PasswordScore.Medium, result.Score); }
public void CheckStrength_VeryWeak_ReturnsVeryWeak1() { var result = PasswordAdvisor.CheckStrength("abcd1"); Assert.AreEqual(PasswordScore.VeryWeak, result.Score); }
public void CheckStrength_Blank_ReturnsVeryBlank() { var result = PasswordAdvisor.CheckStrength("abcd"); Assert.AreEqual(PasswordScore.Blank, result.Score); }
private void InsertPassword() { string pass1 = ""; string pass2 = ""; PasswordAdvisor.PasswordScore pwdScore; while (true) { for (int i = 0; i < 2; i++) { while (true) { string pass = ""; ConsoleKeyInfo key; ClearCurrentConsoleLine(); if (i == 0) { Console.Write("~$ Insert password: "******"~$ Confirm password: "******"*"); } else { if (key.Key == ConsoleKey.Backspace && pass.Length > 0) { pass = pass.Substring(0, (pass.Length - 1)); Console.Write("\b \b"); } } } // Stops Receving Keys Once Enter is Pressed while (key.Key != ConsoleKey.Enter); pwdScore = PasswordAdvisor.CheckStrength(pass); if (pwdScore == PasswordAdvisor.PasswordScore.Blank) { Console.Clear(); PrintHeader(); DefaultMessages.PrintErrorMessage("Password can not be blank!!! Please insert password."); } else { if (i == 0) { pass1 = pass; } else { pass2 = pass; } break; } } } if (pass1 != pass2) { Console.Clear(); PrintHeader(); DefaultMessages.PrintErrorMessage("Password and confirmation do not match!!!"); } else { user.Password = "******"; pwdScore = PasswordAdvisor.CheckStrength(pass1); if (pwdScore == PasswordAdvisor.PasswordScore.VeryWeak) { Console.Clear(); PrintHeader(); DefaultMessages.PrintWarningMessage("Inserted password is weak"); if (WantToContinue()) { Console.Clear(); PrintHeader(); break; } else { user.Password = ""; Console.Clear(); PrintHeader(); } } } } }
public void SetUp() { _advisor = new PasswordAdvisor(); }
/// <summary> /// Checks the password in order to make the GUI. /// </summary> /// <param name="passwordLocal">Password local.</param> /*protected void checkPasswordGUI(string password){ * scorePassword = PasswordAdvisor.CheckStrength (password); * if (oldScorePassword != scorePassword) { //Changer l'affichage - l'icône de force du password. * oldScorePassword = scorePassword; * if (scorePassword == 0) { * * } else if (scorePassword == 1) { * * } * } * }*/ /// <summary> /// This function Checks the password viability. /// </summary> /// <returns><c>true</c>, if password viability was checked, <c>false</c> otherwise.</returns> /// <param name="password">Password (not the hash).</param> protected bool checkPasswordViability(string password) { return(PasswordAdvisor.CheckStrength(password) > 1); }
public RegistrationViewModel(TextBox firstname, TextBox lastname, TextBox phonenumber, TextBox mail, TextBox username, PasswordBox password, PasswordBox confirmpassword, TextBox verifycode, Page currentpage) { int oldran = newran; SendCodeCommand = new RelayCommand(e => { if (password.Password == confirmpassword.Password) { try { ////////MAIL PART////// SmtpClient smtp = new SmtpClient(); int port = int.Parse(ConfigurationManager.AppSettings["SMTP_TLS"]); string host = ConfigurationManager.AppSettings["SMTP_Server_Adress"]; smtp.EnableSsl = true; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; smtp.Host = host; smtp.Port = port; string mypass = ConfigurationManager.AppSettings["MyPassword"]; string mylog = ConfigurationManager.AppSettings["MyLogin"]; smtp.Credentials = new NetworkCredential(mylog, mypass); ////////MAIL MESSAGE PART///////// MailMessage message = new MailMessage(); message.From = new MailAddress(mylog); message.To.Add(mail.Text); message.Subject = ConfigurationManager.AppSettings["Subject"]; message.Body = $@"In order to help maintain the security of your EyeTaxi account we sent you this verification code: {newran} "; smtp.Send(message); MessageBox.Show("Please Verify Your Email"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }, checkCells => { if (firstname.Text.Length > 1 && lastname.Text.Length > 1 && phonenumber.Text.Length > 6) { PasswordScore passwordStrengthScore = PasswordAdvisor.CheckStrength(password.Password); switch (passwordStrengthScore) { case PasswordScore.Blank: case PasswordScore.VeryWeak: return(false); case PasswordScore.Weak: case PasswordScore.Medium: case PasswordScore.Strong: case PasswordScore.VeryStrong: if (password.Password == confirmpassword.Password) { return(true); } break; } } return(false); }); SignUpCommand = new RelayCommand(e => { if (verifycode.Text == oldran.ToString()) { UserDBContext = new UserDBContext(); UserRepo = new UserRepository <User>(UserDBContext); User user = new User(); user.LastName = lastname.Text.ToString(); user.FirstName = firstname.Text.ToString(); user.Email = mail.Text.ToString(); user.PhoneNumber = phonenumber.Text.ToString(); user.Login = username.Text.ToString(); user.Password = password.Password.ToString(); user.IsVerified = true; UserRepo.Add(user); UserDBContext.SaveChanges(); MessageBox.Show("SUCCESS!!!"); currentpage.NavigationService.Navigate(new SignUpPage()); } else { MessageBox.Show("Your Verification Code is not correct"); } }); }
int JudgePasswordStrength(string _userPassword) { var result = PasswordAdvisor.CheckStrength(_userPassword); return((int)result + 1); // 1-6 }
private void btnNext_Click(object sender, EventArgs args) { // Variables bool firstNameTest; bool lastNameTest; bool emailTest; bool NameTest; bool EmailTest; bool PasswordTest; bool AllTestsPassed; string appendError = ""; // Connect to inputed text EditText etFirstName = (EditText)FindViewById(Resource.Id.etFirstName); EditText etLastName = (EditText)FindViewById(Resource.Id.etLastName); EditText etEmail = (EditText)FindViewById(Resource.Id.etEmail); EditText etPassword = (EditText)FindViewById(Resource.Id.etPassword); EditText etConfirmPassword = (EditText)FindViewById(Resource.Id.etConfirmPassword); TextView tvPromptErrors = (TextView)FindViewById(Resource.Id.tvPromptErrors); // Test to make sure first and last name are all chars firstNameTest = IsAllAlphabetic(etFirstName.Text); lastNameTest = IsAllAlphabetic(etLastName.Text); if (firstNameTest == true && lastNameTest == true) { // Do nothing move on to next test NameTest = true; } else { // Append to list of errors to be displayed to user NameTest = false; Context context = ApplicationContext; appendError += "First and last name cannot contain any numbers or special characters" + "\n"; //Toast toast = Toast.MakeText(context, appendError, Android.Widget.ToastLength.Long); //toast.Show(); } ValidEmail email = new ValidEmail(); // Test to make sure email is in correct format emailTest = email.IsValidEmail(etEmail.Text); if (email.IsValidEmail(etEmail.Text)) { // Do nothing go to next test EmailTest = true; } else { // Append to list of errors to be displayed to user EmailTest = false; Context context = ApplicationContext; appendError += "Please make sure email is in correct format ex. [email protected]" + "\n"; } // Test to make sure password is strong PasswordScore passwordStrengthScore = PasswordAdvisor.CheckStrength(etEmail.Text); switch (passwordStrengthScore) { case PasswordScore.VeryWeak: case PasswordScore.Weak: // Send toast for error Context context = ApplicationContext; appendError += "Please make sure password is at least 6 charcters, Uppercase and special charcter" + "\n"; break; case PasswordScore.Medium: case PasswordScore.Strong: case PasswordScore.VeryStrong: // Password deemed strong enough, allow user to be added to database etc PasswordTest = true; break; } // Compare both feilds of inputed password to make sure they are correct bool checkIfEqual = String.Equals(etPassword.Text, etConfirmPassword.Text); if (checkIfEqual == true) { // Go to next test PasswordTest = true; } else { // Append to list of errors to be displayed to user PasswordTest = false; Context context = ApplicationContext; appendError += "Passwords do not match" + "\n"; } // Check to make sure all feilds are filled out if (etFirstName.Length() != 0 && etLastName.Length() != 0 && etEmail.Length() != 0 && etPassword.Length() != 0 && etConfirmPassword.Length() != 0) { // Filed is not empty do your code here. AllTestsPassed = true; } else { // Append to list of errors to be displayed to user AllTestsPassed = false; Context context = ApplicationContext; appendError += "Please fill out all fields" + "\n"; } // If all tests pass procced to next page if (AllTestsPassed == true && PasswordTest == true && NameTest == true && EmailTest == true) { //etFirstName WebClient client = new WebClient(); Uri uri = new Uri("http://packstudy-com.stackstaging.com/registration.php"); NameValueCollection parameter = new NameValueCollection(); parameter.Add("FirstName", etFirstName.Text); parameter.Add("LastName", etLastName.Text); parameter.Add("Email", etEmail.Text); parameter.Add("Password", etPassword.Text); parameter.Add("PhoneNumber", "123456789"); byte[] returnValue = client.UploadValues(uri, parameter); string r = Encoding.ASCII.GetString(returnValue); if (r == "Sucess") { uri = new Uri("http://packstudy-com.stackstaging.com/login.php"); parameter = new NameValueCollection(); parameter.Add("Email", etEmail.Text); parameter.Add("Password", etPassword.Text); returnValue = client.UploadValues(uri, parameter); r = Encoding.ASCII.GetString(returnValue); List <User> users = JsonConvert.DeserializeObject <List <User> >(r); User CurrentUser = users[0]; //since the user name and password work, store it in the shared prefrences ISharedPreferences sharedPrefrences = GetSharedPreferences("MyData", FileCreationMode.Private); var prefEditor = sharedPrefrences.Edit(); prefEditor.PutInt("id", CurrentUser.Id); prefEditor.PutString("FirstName", CurrentUser.FirstName); prefEditor.PutString("LastName", CurrentUser.LastName); prefEditor.PutString("Email", CurrentUser.Email); prefEditor.PutString("Password", CurrentUser.Password); prefEditor.PutString("PhoneNumber", CurrentUser.PhoneNumber); prefEditor.PutString("Username", CurrentUser.Username); prefEditor.Commit(); // Go to next page Intent activityIntent = new Intent(this, typeof(SelectCourses)); StartActivity(activityIntent); } else { Context context = ApplicationContext; appendError += "Did not upload to database correctly"; } } else { // prompt errors that need to be fixed tvPromptErrors.Text = appendError; // Reset errors prompt appendError = ""; } }