Password Verification Qualification Program

Source: Internet
Author: User
Tags repetition

Title Description

Password Requirements:

1. More than 8 bits in length

2. Include uppercase and lowercase letters. Numbers, other symbols, above four species at least three kinds

3. Can not have the same length of over 2 substring repetition

Enter a description

  One or more sets of substrings that are longer than 2. Each group takes up one row

Output description

  If required output: OK, otherwise output ng

Input example

021abc9000021abc9abc1021abc9000 021$BC 9000

Output example

Okngngok

Test code

1 ImportJava.util.Scanner;2 3  Public classMain {4     //more than 8 bits in length5      Public Static Booleanchecklength (String password) {6         if(Password.equals (NULL) || Password.length () <= 8){7             return false;8         }9         return true;Ten     } One     //include uppercase and lowercase letters. Numbers, other symbols, above four species at least three A      Public Static Booleancheckcharkinds (String password) { -         intUppercase = 0, lowercase = 0, digit = 0, other = 0; -         Char[] ch =Password.tochararray (); the          for(inti = 0; I < password.length (); i++) { -             if(Character.isuppercase (Ch[i])) { -Uppercase = 1; -}Else if(Character.islowercase (Ch[i])) { +lowercase = 1; -}Else if(Character.isdigit (Ch[i])) { +digit = 1; A}Else { atother = 1; -             } -         } -         if(uppercase + lowercase + digit + other >= 3) { -             return true; -         } in         return false; -     } to     //cannot have substring repetition of the same length of over 2 +      Public Static Booleancheckcharrepeat (String password) { -          for(inti = 0; I < Password.length ()-2; i++) { theString str = password.substring (i, i + 3); *              for(intj = i + 1; J < Password.length ()-2; J + +) { $                 if(Password.substring (J). Contains (str)) {Panax Notoginseng                     return false; -                 } the             } +         } A         return true; the     } +  -      Public Static voidMain (string[] args) { $Scanner sc =NewScanner (system.in); $          while(Sc.hasnextline ()) { -String Password =sc.nextline (); -             if(Checklength (password) && checkcharkinds (password) &&checkcharrepeat (password)) { theSystem.out.println ("OK"); -}Else {WuyiSystem.out.println ("NG"); the             } -         } Wu sc.close (); -     } About}

Password Verification Qualification Program

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.