Back to Exposed

Pbkdf2Hasher

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

1.5.02.9 KB
Original Source

Pbkdf2Hasher

class Pbkdf2Hasher(secret: CharSequence = "", saltLength: Int = DEFAULT_SALT_LENGTH, iterations: Int = DEFAULT_ITERATIONS, algorithm: Pbkdf2PasswordEncoder.SecretKeyFactoryAlgorithm = SecretKeyFactoryAlgorithm.PBKDF2WithHmacSHA256) : PasswordEncoderHasher

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

Encoded values are the hex encoded salt and hash, 96 characters long with the default parameters, varying with saltLength and the hash width of algorithm.

Parameters

secret

Optional secret, sometimes called a pepper, mixed into every hash. Unlike the salt it is not stored alongside the hash, so it has to be kept and supplied identically in order to verify existing values.

saltLength

Length in bytes of the randomly generated salt

iterations

Number of hashing iterations to perform

algorithm

Pseudorandom function to apply on each iteration

Members

Constructors

Pbkdf2Hasher

Link copied to clipboard

constructor(secret: CharSequence = "", saltLength: Int = DEFAULT_SALT_LENGTH, iterations: Int = DEFAULT_ITERATIONS, algorithm: Pbkdf2PasswordEncoder.SecretKeyFactoryAlgorithm = SecretKeyFactoryAlgorithm.PBKDF2WithHmacSHA256)

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