Java Login Password Validation

Source: Internet
Author: User

Password Verification requirements:

1) Password control can only enter letters, numbers, special symbols ([email protected]#$%^&* () _+[]{}|\;: ' ",./<>?)
2) length 6-16 digits, must include 2 kinds of letters, numbers, special symbols
3) password cannot contain user name information


Determine if the password contains a number: contains return 1, does not contain return 0
int i = newpwd.matches (". *\\d+.*")? 1:0;

Determine if the password contains letters: contains return 1, does not contain return 0
Int j = newpwd.matches (". *[a-za-z]+.*")? 1:0;

Determine if the password contains special symbols (email protected]#$%^&* () _+|<>,.? /:;‘ []{}\): contains return 1, does not contain return 0
int k = newpwd.matches (". *[[email protected]#$%^&* () _+|<>,.? /:;‘ \\[\\]{}\"]+.*") ? 1:0;

Determine if the password length is 6-16 bits
int L = newpwd.length ();

Determine if the password contains a user name
Boolean contains = Newpwd.contains (userId);

If (i + j + K < 2 | | L < 6 | | L > | | | Contains) {
return Password error;
}

Java Login Password Validation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.