Advertisement
Jonas_3k

Password strength check

Feb 19th, 2022
1,249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. package br.com.jonasdsg.app;
  2.  
  3. import java.util.Scanner;
  4. import java.util.regex.Pattern;
  5.  
  6. public class PasswordCheck {
  7.  
  8.     public static void main(String[] args) {
  9.         Scanner teclado = new Scanner(System.in);
  10.         System.out.print("Digite a senha: ");
  11.         String senha = teclado.nextLine();
  12.         teclado.close();
  13.         Boolean check =
  14.             Pattern.compile("[A-Z]+").matcher(senha).find() // Verifica caracteres Maiusculos
  15.         &&  Pattern.compile("[a-z]+").matcher(senha).find() // Verifica caracteres Minusculos
  16.         &&  Pattern.compile("!|@|#|\\$|%|\\^|&|\\*|\\(|\\)|-|\\+").matcher(senha).find() // Verifica os caracteres especiais
  17.         &&  senha.length()>=6;
  18.          
  19.         System.out.println("Password "+ ( check ? "Válido" : "Inválido"));
  20.     }
  21.  
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement