Back to Exposed

SCryptHasher

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

1.5.03.0 KB
Original Source

SCryptHasher

class SCryptHasher(cpuCost: Int = DEFAULT_CPU_COST, memoryCost: Int = DEFAULT_MEMORY_COST, parallelization: Int = DEFAULT_PARALLELIZATION, keyLength: Int = DEFAULT_KEY_LENGTH, saltLength: Int = DEFAULT_SALT_LENGTH) : PasswordEncoderHasher

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

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

Parameters

cpuCost

CPU cost of the algorithm, as a power of 2 greater than 1

memoryCost

Memory cost of the algorithm

parallelization

Parallelization of the algorithm

keyLength

Length in bytes of the generated key

saltLength

Length in bytes of the randomly generated salt

Throws

IllegalStateException

If BouncyCastle is not on the runtime classpath.

Members

Constructors

SCryptHasher

Link copied to clipboard

constructor(cpuCost: Int = DEFAULT_CPU_COST, memoryCost: Int = DEFAULT_MEMORY_COST, parallelization: Int = DEFAULT_PARALLELIZATION, keyLength: Int = DEFAULT_KEY_LENGTH, saltLength: Int = DEFAULT_SALT_LENGTH)

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