Package rs.baselib.crypto
Class Sha256PasswordHasher
java.lang.Object
rs.baselib.crypto.Sha256PasswordHasher
- All Implemented Interfaces:
ExtendedPasswordHasher,PasswordHasher
public class Sha256PasswordHasher extends java.lang.Object implements ExtendedPasswordHasher
Uses salted SHA256 hashes from
Sha2Crypt.- Since:
- 1.2.9
- Author:
- ralph
- See Also:
Sha2Crypt
-
Field Summary
Fields Modifier and Type Field Description static ExtendedPasswordHasherINSTANCEA static instance of the SHA512 hasherstatic java.lang.StringPREFIXThe prefix that is present for hashes of this algorithm -
Constructor Summary
Constructors Constructor Description Sha256PasswordHasher()Constructor. -
Method Summary
Modifier and Type Method Description java.lang.StringgetPasswordHash(java.lang.String plainPassword)Returns a hash of the given plain password.booleanisHash(java.lang.String passwordHash)Returns whether the given hash string was produced using the implemented hashing algorithm.booleantestPassword(java.lang.String plainPassword, java.lang.String passwordHash)Tests a plain Password whether it is the same as a previously hashed password.
-
Field Details
-
PREFIX
public static final java.lang.String PREFIXThe prefix that is present for hashes of this algorithm- See Also:
- Constant Field Values
-
INSTANCE
A static instance of the SHA512 hasher
-
-
Constructor Details
-
Sha256PasswordHasher
public Sha256PasswordHasher()Constructor.
-
-
Method Details
-
getPasswordHash
public java.lang.String getPasswordHash(java.lang.String plainPassword)Returns a hash of the given plain password.- Specified by:
getPasswordHashin interfacePasswordHasher- Parameters:
plainPassword- the password to be hashed- Returns:
- the hash of the password
-
testPassword
public boolean testPassword(java.lang.String plainPassword, java.lang.String passwordHash)Tests a plain Password whether it is the same as a previously hashed password.- Specified by:
testPasswordin interfacePasswordHasher- Parameters:
plainPassword- the plain password to be checkedpasswordHash- the hash of another password- Returns:
truewhen both passwords match each other
-
isHash
public boolean isHash(java.lang.String passwordHash)Returns whether the given hash string was produced using the implemented hashing algorithm.- Specified by:
isHashin interfaceExtendedPasswordHasher- Parameters:
passwordHash- the hash to be checked- Returns:
truewhen this hash was produced by this password hasher (or using the same algorithm).
-