Skip to content

crypto.bcrypt #

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'

fn 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.

fn generate_from_password #

fn generate_from_password(password []u8, cost int) !string

generate_from_password return a bcrypt string from Hashed struct.

fn generate_salt #

fn generate_salt() string

generate_salt generate a string to be treated as a salt.

struct Hashed #

struct Hashed {
mut:
	hash  []u8
	salt  []u8
	cost  int
	major string
	minor string
}

fn (Hashed) free #

unsafe
fn (mut h Hashed) free()

free the resources taken by the Hashed h