Class ModularCrypt
java.lang.Object
org.wildfly.security.password.util.ModularCrypt
Helper utility methods for operation on passwords based on the Modular Crypt Format(MCF).
- Author:
- Juraci Paixão Kröhling, David M. Lloyd
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcomposePassword(ByteArrayOutputStream out, Password password) static PasswordcreatePassword(byte[] password, String algorithm) static Passworddecode(char[] cryptString) Decode the given char array and creates aPasswordinstance.static PasswordDecode the given string and creates aPasswordinstance.static char[]Encode the givenPasswordto a char array.static StringencodeAsString(Password password) Encode the givenPasswordto a string.static StringidentifyAlgorithm(char[] chars) Attempt to identify the algorithm used by the given crypt string password.
-
Method Details
-
identifyAlgorithm
Attempt to identify the algorithm used by the given crypt string password.- Parameters:
chars- the password crypt string characters- Returns:
- the algorithm name, or
nullif no algorithm could be guessed
-
encode
Encode the givenPasswordto a char array.- Parameters:
password- the password to encode- Returns:
- a char array representing the encoded password
- Throws:
InvalidKeySpecException- if the given password is not supported or could be encoded
-
encodeAsString
Encode the givenPasswordto a string.- Parameters:
password- the password to encode- Returns:
- a string representing the encoded password
- Throws:
InvalidKeySpecException- if the given password is not supported or could be encoded
-
decode
Decode the given string and creates aPasswordinstance.- Parameters:
cryptString- the string representing the encoded format of the password- Returns:
- a
Passwordinstance created from the given string - Throws:
InvalidKeySpecException- if the given password is not supported or could be decoded
-
decode
Decode the given char array and creates aPasswordinstance.- Parameters:
cryptString- the char array representing the encoded format of the password- Returns:
- a
Passwordinstance created from the given string - Throws:
InvalidKeySpecException- if the given password is not supported or could be decoded
-
createPassword
public static Password createPassword(byte[] password, String algorithm) throws InvalidKeySpecException - Throws:
InvalidKeySpecException
-
composePassword
- Throws:
IOException
-