Hashed

class Hashed(hasher: Hasher, val encodedValue: String)

A hashed column holds these rather than strings, which is what keeps a plaintext value from being stored in one by accident, or compared against one in SQL. Assigning a Hashed read from the database back to a column stores it unchanged, without hashing it a second time.

Constructing one directly wraps encodedValue as it is, without hashing it. Do that to adopt hashes produced elsewhere, such as when migrating existing values into a hashed column; to hash a plaintext value, use Hasher.hash.

Constructors

Link copied to clipboard
constructor(hasher: Hasher, encodedValue: String)

Properties

Link copied to clipboard

The encoded hash, as stored in the database.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun matches(plainText: String): Boolean

Returns whether plainText hashes to this value, as determined by the Hasher that produced it.

Link copied to clipboard
open override fun toString(): String