Package org.jasypt.util.password
Class BasicPasswordEncryptor
- java.lang.Object
-
- org.jasypt.util.password.BasicPasswordEncryptor
-
- All Implemented Interfaces:
PasswordEncryptor
public final class BasicPasswordEncryptor extends java.lang.Object implements PasswordEncryptor
Utility class for easily performing password digesting and checking.
This class internally holds a
StandardStringDigester
configured this way:- Algorithm: MD5.
- Salt size: 8 bytes.
- Iterations: 1000.
The required steps to use it are:
- Create an instance (using new).
- Perform the desired
encryptPassword(String)
orcheckPassword(String, String)
operations.
This class is thread-safe
- Since:
- 1.2 (class existed as org.jasypt.util.PasswordEncryptor since 1.0)
-
-
Field Summary
Fields Modifier and Type Field Description private StandardStringDigester
digester
-
Constructor Summary
Constructors Constructor Description BasicPasswordEncryptor()
Creates a new instance of BasicPasswordEncryptor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkPassword(java.lang.String plainPassword, java.lang.String encryptedPassword)
Checks an unencrypted (plain) password against an encrypted one (a digest) to see if they match.java.lang.String
encryptPassword(java.lang.String password)
Encrypts (digests) a password.
-
-
-
Field Detail
-
digester
private final StandardStringDigester digester
-
-
Method Detail
-
encryptPassword
public java.lang.String encryptPassword(java.lang.String password)
Encrypts (digests) a password.- Specified by:
encryptPassword
in interfacePasswordEncryptor
- Parameters:
password
- the password to be encrypted.- Returns:
- the resulting digest.
- See Also:
StandardStringDigester.digest(String)
-
checkPassword
public boolean checkPassword(java.lang.String plainPassword, java.lang.String encryptedPassword)
Checks an unencrypted (plain) password against an encrypted one (a digest) to see if they match.- Specified by:
checkPassword
in interfacePasswordEncryptor
- Parameters:
plainPassword
- the plain password to check.encryptedPassword
- the digest against which to check the password.- Returns:
- true if passwords match, false if not.
- See Also:
StandardStringDigester.matches(String, String)
-
-