Back to Exposed

Argon2Hasher

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

1.5.03.4 KB
Original Source

Argon2Hasher

class Argon2Hasher(saltLength: Int = DEFAULT_SALT_LENGTH, hashLength: Int = DEFAULT_HASH_LENGTH, parallelism: Int = DEFAULT_PARALLELISM, memory: Int = DEFAULT_MEMORY, iterations: Int = DEFAULT_ITERATIONS) : PasswordEncoderHasher

Hasher that uses the Argon2id algorithm, the first choice recommended by OWASP, salting each value individually.

Encoded values follow the PHC string format and are 97 characters long with the default parameters, varying with saltLength, hashLength, and the printed length of the remaining parameters.

This requires BouncyCastle (org.bouncycastle:bcprov-jdk18on) on the runtime classpath, which exposed-crypt does not depend on.

Parameters

saltLength

Length in bytes of the randomly generated salt

hashLength

Length in bytes of the generated hash

parallelism

Number of lanes used by the algorithm

memory

Amount of memory in kibibytes used by the algorithm

iterations

Number of passes over the memory

Throws

IllegalStateException

If BouncyCastle is not on the runtime classpath.

Members

Constructors

Argon2Hasher

Link copied to clipboard

constructor(saltLength: Int = DEFAULT_SALT_LENGTH, hashLength: Int = DEFAULT_HASH_LENGTH, parallelism: Int = DEFAULT_PARALLELISM, memory: Int = DEFAULT_MEMORY, iterations: Int = DEFAULT_ITERATIONS)

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