Class Password
java.lang.Object
zeroecho.sdk.util.Password
Utility class for generating random passwords and secure random byte arrays.
This class provides methods to:
- Generate cryptographically secure random byte arrays of specified length.
- Generate random passwords composed of characters derived from random bytes.
Randomness is supplied by the shared thread-safe source in
RandomSupport.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic char[]generatePrintablePasswordChars(int length) Generates a printable password in a caller-owned character array.static byte[]generateRandom(byte[] password) Fills the supplied array with cryptographically strong random bytes.
-
Method Details
-
generateRandom
public static byte[] generateRandom(byte[] password) Fills the supplied array with cryptographically strong random bytes.- Parameters:
password- array to fill; must not benull- Returns:
password- Throws:
NullPointerException- ifpasswordisnull
-
generatePrintablePasswordChars
public static char[] generatePrintablePasswordChars(int length) Generates a printable password in a caller-owned character array.- Parameters:
length- desired password length; must be positive- Returns:
- a newly allocated printable password
- Throws:
IllegalArgumentException- iflengthis not positive
-