Back to Exposed

PasswordEncoderHasher

docs/api/exposed-crypt/org.jetbrains.exposed.v1.crypt/-password-encoder-hasher/index.html

1.5.02.3 KB
Original Source

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:

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

Content copied to clipboard

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

Inheritors

Argon2Hasher

BCryptHasher

Pbkdf2Hasher

SCryptHasher

Members

Constructors

PasswordEncoderHasher

Link copied to clipboard

constructor(passwordEncoder: PasswordEncoder)

Functions

hash

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.

matches

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.

Generated by Dokka © 2026 Copyright