public class PasswordGenerator extends Object
Copyright 2005 Sans Pareil Technologies, Inc.
| Constructor and Description |
|---|
PasswordGenerator()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
byteToInt(byte byteValue)
Convert a byte value into a postive integer.
|
boolean |
checkComplex(char[] password)
Check the specified password value for quality.
|
boolean |
checkSimple(char[] password)
Check the specified password value for quality using simple rules.
|
char[] |
generate(int length)
Generate a random password of the specified length.
|
char[] |
generate(int length,
char[] characters)
Generate a random password of the specified length and restricted
to the characters specified.
|
protected int |
getIntFromByte(byte[] bytes)
Convert a byte value returned by the random number generator
(
random) to an integer that may be used to index into
the allowable characters array. |
public PasswordGenerator()
public char[] generate(int length)
length - The desired length of the password.generate( int, char[] )public char[] generate(int length,
char[] characters)
checkSimple(char[]) and to ensure that the generated value is good
enough.
Note: There is a possibility that this method can go into
an infinite loop. This can happen if the characters
array contains only those characters that make checkComplex(char[]) always return false.
length - The desired length of the password.characters - The array of valid characters thay may be used
in the password.checkComplex(char[])public boolean checkSimple(char[] password)
password - The password that is to be checked.true if the specified password
satisfies the requirements.checkComplex(char[])public boolean checkComplex(char[] password)
Note: There is no guarantee that the password generated
by the generate( int, char[] ) method will satisfy
these rules.
password - The password that is to be checked.true if the specified password
satisfies the requirements.checkSimple(char[])protected int getIntFromByte(byte[] bytes)
random) to an integer that may be used to index into
the allowable characters array.bytes - The byte values returned by the random number
generator.protected int byteToInt(byte byteValue)
byteValue - The byte that is to be converted into an integer.