Hasher
interface Hasher
Base class responsible for the one-way hashing of data.
Unlike Encryptor, a Hasher cannot recover the original value: the only operation available on a stored hash is checking whether some plaintext produces it. Use this for values that never need to be read back, such as passwords.
BCryptHasher, Argon2Hasher, Pbkdf2Hasher, and SCryptHasher cover the algorithms recommended by the OWASP password storage cheat sheet. To hash with something else, wrap any Spring Security PasswordEncoder in a PasswordEncoderHasher, or implement the two operations declared here:
class CustomHasher : Hasher {
override fun hash(plainText: String): Hashed = Hashed(this, customLibrary.hash(plainText))
override fun matches(plainText: String, encodedValue: String): Boolean =
customLibrary.verify(plainText, encodedValue)
}Content copied to clipboard