is Password Valid: 8-16 length and A-Z a-a and 0-9 - Android java.security

Android examples for java.security:Password

Description

is Password Valid: 8-16 length and A-Z a-a and 0-9

Demo Code

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static boolean isPswValid(String sequence) {
        if (!(sequence.length() >= 8 && sequence.length() <= 16)) {
            return false;
        }//from w w w .  jav a  2 s . co  m
        Pattern pattern = Pattern.compile("^([a-zA-Z0-9]){8,16}$");
        Matcher matcher = pattern.matcher(sequence);
        return matcher.find();
    }

}

Related Tutorials