hash

fun Column<Hashed>.hash(plainText: String): Hashed

Hashes plainText with the Hasher this column was declared with, ready to be stored in it.

Using this rather than a separately held Hasher rules out hashing a value with one algorithm and storing it in a column that verifies with another, which the column cannot detect and which makes every later Hashed.matches fail. It is the only way to hash for a column declared without an explicit hasher:

object Users : IntIdTable() {
val password = text("password").hashed()
}

Users.insert { it[password] = Users.password.hash("s3cret") }

Return

The Hashed result of applying this column's Hasher to plainText.

Parameters

plainText

Value to hash


@JvmName(name = "hashNullable")
fun Column<Hashed?>.hash(plainText: String): Hashed

Hashes plainText with the Hasher this nullable column was declared with, ready to be stored in it.

Using this rather than a separately held Hasher rules out hashing a value with one algorithm and storing it in a column that verifies with another, which the column cannot detect and which makes every later Hashed.matches fail. It is the only way to hash for a column declared without an explicit hasher:

object Users : IntIdTable() {
val recoveryCode = text("recovery_code").nullable().hashed()
}

Users.insert { it[recoveryCode] = Users.recoveryCode.hash("r3covery") }

Return

The Hashed result of applying this column's Hasher to plainText.

Parameters

plainText

Value to hash