Package rs.baselib.crypto
Class Md5PasswordHasher
java.lang.Object
rs.baselib.crypto.Md5PasswordHasher
- All Implemented Interfaces:
ExtendedPasswordHasher
,PasswordHasher
Uses salted MD5 hashes from
Md5Crypt
.- Since:
- 1.2.9
- Author:
- ralph
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ExtendedPasswordHasher
A static instance of the MD5 hasherstatic final String
The prefix that is present for hashes of this algorithm -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetPasswordHash
(String plainPassword) Returns a hash of the given plain password.boolean
Returns whether the given hash string was produced using the implemented hashing algorithm.boolean
testPassword
(String plainPassword, String passwordHash) Tests a plain Password whether it is the same as a previously hashed password.
-
Field Details
-
PREFIX
The prefix that is present for hashes of this algorithm- See Also:
-
INSTANCE
A static instance of the MD5 hasher
-
-
Constructor Details
-
Md5PasswordHasher
public Md5PasswordHasher()Constructor.
-
-
Method Details
-
getPasswordHash
Returns a hash of the given plain password.- Specified by:
getPasswordHash
in interfacePasswordHasher
- Parameters:
plainPassword
- the password to be hashed- Returns:
- the hash of the password
-
testPassword
Tests a plain Password whether it is the same as a previously hashed password.- Specified by:
testPassword
in interfacePasswordHasher
- Parameters:
plainPassword
- the plain password to be checkedpasswordHash
- the hash of another password- Returns:
true
when both passwords match each other
-
isHash
Returns whether the given hash string was produced using the implemented hashing algorithm.- Specified by:
isHash
in interfaceExtendedPasswordHasher
- Parameters:
passwordHash
- the hash to be checked- Returns:
true
when this hash was produced by this password hasher (or using the same algorithm).
-