Skip to content

Instantly share code, notes, and snippets.

@hellosagar
Created May 1, 2019 05:12
Show Gist options
  • Save hellosagar/96891bfcb556276aa41b1228f88b518c to your computer and use it in GitHub Desktop.
Save hellosagar/96891bfcb556276aa41b1228f88b518c to your computer and use it in GitHub Desktop.
import java.net.PasswordAuthentication;
public class password {
public static void main(String[] args) {
String pass="Sagar@123aaa";
boolean flag0=false;
boolean flag1=false;
boolean flag2=false;
boolean flag3=false;
int a=pass.length();
for (int i=0;i<pass.length();i++){
int b=pass.charAt(i);
if (b>=65&&b<=97){
flag0=true;
}
else if (b>=97&&b<=122){
flag1 = true;
}
else if (b>=33&&b<=47||b>=91&&b<=96||b>=58&&b<=64||b>=123&&b<=126){
flag2= true;
}
else if (b>=48&&b<=57){
flag3=true;
} else{
System.out.println("PASSWORD INVALID");
}
}
if (flag0==true&&flag1==true&&flag2==true&&flag3==true&&a>=8&&a<=12){
System.out.println("VALID PASSWORD!");
}else{
System.out.println("INVALID PASSWORD!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment