1.8 KiB
1.8 KiB
module bcrypt
Contents
Constants
const min_cost = 4
const max_cost = 31
const default_cost = 10
const salt_length = 16
const max_crypted_hash_size = 23
const encoded_salt_size = 22
const encoded_hash_size = 31
const min_hash_size = 59
const major_version = '2'
const minor_version = 'a'
compare_hash_and_password
fn compare_hash_and_password(password []u8, hashed_password []u8) !
compare_hash_and_password compares a bcrypt hashed password with its possible hashed version.
generate_from_password
fn generate_from_password(password []u8, cost int) !string
generate_from_password return a bcrypt string from Hashed struct.
generate_salt
fn generate_salt() string
generate_salt generate a string to be treated as a salt.
Hashed
struct Hashed {
mut:
hash []u8
salt []u8
cost int
major string
minor string
}
free
fn (mut h Hashed) free()
free the resources taken by the Hashed h