crypt: Index | Files | Directories

package crypt

import ""


Package Files

algorithm.go argon2i.go argon2id.go base64.go bcrypt.go crypt.go md5.go settings.go sha256.go sha512.go util.go


const Argon2iPrefix = "$argon2i$"

Argon2iPrefix defines the settings prefix for argon2i hashes.

const Argon2idPrefix = "$argon2id$"

Argon2idPrefix defines the settings prefix for argon2id hashes.

const BCryptPrefix = "$2a$"

BCryptPrefix defines the settings prefix for bcrypt hashes.

const MD5Prefix = "$1$"

MD5Prefix defines the settings prefix for md5 hashes.

const SHA256Prefix = "$5$"

SHA256Prefix defines the settings prefix for sha256 hashes.

const SHA512Prefix = "$6$"

SHA512Prefix defines the settings prefix for sha512 hashes.


var Base64Encoding = base64.StdEncoding.WithPadding(base64.NoPadding)

Base64Encoding implements the crypt-specific base63 encoding.

func Argon2iSettings Uses

func Argon2iSettings(m, t, p, k int, salts ...string) (string, error)

Argon2iSettings returns argon2i settings with the provided parameter.

func Argon2idSettings Uses

func Argon2idSettings(m, t, p, k int, salts ...string) (string, error)

Argon2idSettings returns argon2id settings with the provided parameter.

func BCryptSettings Uses

func BCryptSettings(cost int, salts ...string) (string, error)

BCryptSettings returns bcrypt settings with the provided parameter.

func Crypt Uses

func Crypt(password, settings string) (string, error)

Crypt hashes the provided password using the provided salt.

func Encode24BitBase64 Uses

func Encode24BitBase64(src []byte) []byte

Encode24BitBase64 implements a special version of base64 that is used with md5, sha256 and sha512.

func RegisterAlgorithm Uses

func RegisterAlgorithm(prefix string, algorithm Algorithm)

RegisterAlgorithm registers an algorithm under the provided prefix.

func Settings Uses

func Settings(settings string) string

Settings removes the hash from the provided settings and returns the result.

type Algorithm Uses

type Algorithm func(string, string) (string, error)

Algorithm defines a algorithm.

type Parameter Uses

type Parameter map[string]string

Parameter defines a parameter map.

func DecodeSettings Uses

func DecodeSettings(settings string) (code string, parameter Parameter, salt string, hash string, err error)

DecodeSettings decodes the provided settings string into it's parts.

func (Parameter) GetInt Uses

func (p Parameter) GetInt(key string, defaultValue int) int

GetInt tries to return an int value from the parameter map and returns the provided defaultValue on failure.


bcryptPackage bcrypt implements Provos and Mazières's bcrypt adaptive hashing algorithm.

Package crypt imports 12 packages (graph). Updated 2020-05-21. Refresh now. Tools for package owners.