Interface PasswordHasher
public interface PasswordHasher
Port that hashes and checks passwords. The implementation chooses the algorithm; an encoded password carries its
own prefix so that older encodings can still be checked and upgraded. Never used with a
null argument.-
Method Summary
Modifier and TypeMethodDescriptionencode(CharSequence rawPassword) Encodes a clear-text password (or a client secret) with the current algorithm.booleanmatches(CharSequence rawPassword, String encodedPassword) Checks a clear-text password against an encoded one.booleanupgradeEncoding(String encodedPassword) Tells whether a stored encoding is weaker than the current algorithm and should be replaced the next time the clear-text password is known.
-
Method Details
-
encode
Encodes a clear-text password (or a client secret) with the current algorithm.- Parameters:
rawPassword- the clear-text value.- Returns:
- the encoded value, including its encoding prefix.
-
matches
Checks a clear-text password against an encoded one.- Parameters:
rawPassword- the clear-text value.encodedPassword- the stored encoded value.- Returns:
truewhen they match.
-
upgradeEncoding
Tells whether a stored encoding is weaker than the current algorithm and should be replaced the next time the clear-text password is known.- Parameters:
encodedPassword- the stored encoded value.- Returns:
truewhen the password should be re-encoded.
-