Advertisement
Guest User

evalpasswd.java

a guest
Oct 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package MainPackage;
  7.  
  8. import javax.swing.JOptionPane;
  9.  
  10. /**
  11.  *
  12.  * @author benja
  13.  */
  14. public class evalpasswd {
  15.        public String userpass;
  16.  
  17. public evalpasswd (String userpass) {
  18.        this.userpass = userpass;
  19.     }
  20.    
  21. public String getPass() {
  22.    
  23.        String passwd = userpass;
  24.        String pattern = "(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=])(?=\\S+$).{8,}";
  25.        //Equation to validate password must contain: at least one uppper case and at least one lower case letter, at least one special character, at least one digit
  26.        String validstatus = String.valueOf(passwd.matches(pattern)); //Checks if password matches the equation
  27.      
  28.        return validstatus; //Returns whether or not the password entered is valid
  29.  
  30. } //End of method
  31. } //End of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement