PasswordEncoderHasher

open class PasswordEncoderHasher(passwordEncoder: PasswordEncoder) : Hasher

Hasher that delegates to a Spring Security passwordEncoder.

This is the base of BCryptHasher, Argon2Hasher, Pbkdf2Hasher, and SCryptHasher, and can also be used directly with any other implementation, including a DelegatingPasswordEncoder for a column whose existing values were hashed by an algorithm that is being migrated away from:

val hasher = PasswordEncoderHasher(
DelegatingPasswordEncoder(
"argon2",
mapOf("argon2" to Argon2PasswordEncoder(...), "bcrypt" to BCryptPasswordEncoder())
)
)

To hash with something that is not a PasswordEncoder at all, implement Hasher directly.

Inheritors

Constructors

Link copied to clipboard
constructor(passwordEncoder: PasswordEncoder)

Functions

Link copied to clipboard
open override fun hash(plainText: String): Hashed

Hashes plainText into the value to be stored, salting it if the algorithm supports salting.

Link copied to clipboard
open override fun matches(plainText: String, encodedValue: String): Boolean

Returns whether plainText hashes to encodedValue, which is expected to be an already hashed value.