Passay Tutorial on Passay Password Generation

passwordgenerator helps in generating password using given policy. consider the following policy:

  • length of password should be 8 characters.

  • a password should contains each of the following: upper, lower, digit and a symbol.

example

the below example shows the generation of a password against above policy using passay library.

import org.passay.characterrule;
import org.passay.englishcharacterdata;
import org.passay.passwordgenerator;

public class passayexample {
   public static void main(string[] args) {
      characterrule alphabets = new characterrule(englishcharacterdata.alphabetical);
      characterrule digits = new characterrule(englishcharacterdata.digit);
      characterrule special = new characterrule(englishcharacterdata.special);

      passwordgenerator passwordgenerator = new passwordgenerator();
      string password = passwordgenerator.generatepassword(8, alphabets, digits, special);
      system.out.println(password);
   }
}

output

?\de~@c3