BCryptHasher

class BCryptHasher(strength: Int = DEFAULT_STRENGTH) : PasswordEncoderHasher

Hasher that uses the bcrypt algorithm, salting each value individually.

Encoded values are always 60 characters long.

Parameters

strength

Log rounds of hashing work to perform, between 4 and 31, where each increment doubles the time taken. Defaults to the same value as Spring Security's BCryptPasswordEncoder.

Constructors

Link copied to clipboard
constructor(strength: Int = DEFAULT_STRENGTH)

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.