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

If BouncyCastle is not on the runtime classpath.

Constructors

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

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.