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 []byte, hashed_password []byte) ?

compare_hash_and_password compares a bcrypt hashed password with its possible hashed version.

fn generate_from_password #

fn generate_from_password(password []byte, cost int) ?string

fn generate_salt #

fn generate_salt() string

generate_salt generate a string to be treated as a salt.

struct Hashed #

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