KScript docs
EN

password_hash fields and methods

A field is a plain fact about the value, read with a dot and no brackets: $value.name. A method takes arguments or does work, and is called with ->: $value->name(arguments), or with the value piped in: $value |> name(arguments).

From KScript.Data

These need <import package="KScript.Data" />import KScript.Data. See KScript.Data.

#password_hash->needs_rehash(algorithm?: argon2id|bcrypt) → bool KScript.Data

True when the hash was made with weaker settings (or another algorithm) than ->hash() uses now, so it should be made again at the next sign-in.
ParameterTakes
algorithm optionalone of these words: argon2id|bcrypt
Example
<import package="KScript.Data" />
<model name="Account" fields="email: email, password: password" />
<do>$db->create_table(Account)</do>
<let name="account" value="Account->create(email: 'joan@example.com', password: 'correct horse')" />
<echo>{ $account.password->needs_rehash('bcrypt') }</echo>
import KScript.Data
model Account {
  email: email
  password: password
}
$db->create_table(Account)
$account = Account->create(email: 'joan@example.com', password: 'correct horse')
echo $account.password->needs_rehash('bcrypt')

#password_hash->verify(password) → bool KScript.Data

True when the password someone typed is the one this hash was made from: $user.password->verify($form.password).
Example
<import package="KScript.Data" />
<model name="Account" fields="email: email, password: password" />
<do>$db->create_table(Account)</do>
<let name="account" value="Account->create(email: 'joan@example.com', password: 'correct horse')" />
<echo>{ $account.password->verify('correct horse') } { $account.password->verify('wrong') }</echo>
import KScript.Data
model Account {
  email: email
  password: password
}
$db->create_table(Account)
$account = Account->create(email: 'joan@example.com', password: 'correct horse')
echo "{ $account.password->verify('correct horse') } { $account.password->verify('wrong') }"

Methods from any