Skip to content

crypto.bcrypt #

Constants #

const (
	min_cost              = 4
	max_cost              = 31
	default_cost          = 10
	salt_length           = 16
	max_crypted_hash_size = 23
	encoded_salt_size     = 22
	encoded_hash_size     = 31
	min_hash_size         = 59

	major_version         = '2'
	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