Class ModularCrypt
- java.lang.Object
 - 
- org.wildfly.security.password.util.ModularCrypt
 
 
- 
public final class ModularCrypt extends Object
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
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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(String cryptString)Decode the given string and creates aPasswordinstance.static char[]encode(Password password)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 Detail
- 
identifyAlgorithm
public static String identifyAlgorithm(char[] chars)
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
public static char[] encode(Password password) throws InvalidKeySpecException
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
public static String encodeAsString(Password password) throws InvalidKeySpecException
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
public static Password decode(String cryptString) throws InvalidKeySpecException
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
public static Password decode(char[] cryptString) throws InvalidKeySpecException
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
public static void composePassword(ByteArrayOutputStream out, Password password) throws IOException
- Throws:
 IOException
 
 - 
 
 -