crypto

package
v0.0.0-...-4334ecd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHashComponentUnreadable = errors.New("argon2: unreadable component in hashed password")
	ErrHashComponentMismatch   = errors.New("argon2: hashed password components mismatch")
	ErrAlgorithmMismatch       = errors.New("argon2: algorithm mismatch")
	ErrIncompatibleVersion     = errors.New("argon2: incompatible version")
)

Errors returned by Argon2PasswordHashAlgorithm.

View Source
var ErrUnimplementedPasswordHashAlgorithm = errors.New("password hash algorithm is not" +
	" implemented yet")

Functions

func ByteSliceToUint64

func ByteSliceToUint64(b []byte) uint64

ByteSliceToUint64 converts byte slice to uint64

func GetNamespace

func GetNamespace(stateAddressByteSlice []byte) []byte

GetNamespace from state address byte slice

func GetNamespaceFromStateAddressHexString

func GetNamespaceFromStateAddressHexString(stateAddressHexString string) []byte

GetNamespaceFromStateAddressHexString returns address byte slice from state address hex string

func GetRandomString

func GetRandomString(length int) string

GetRandomString returns a securely generated random string.

func GetStateAddress

func GetStateAddress(namespace []byte, key []byte) []byte

GetStateAddress generates state address from namespace and key

func GetStateAddressFromHexString

func GetStateAddressFromHexString(stateAddressHexString string) []byte

GetStateAddressFromHexString converts state hex string to byte slice

func GetStateAddressHexString

func GetStateAddressHexString(namespace []byte, key []byte) string

GetStateAddressHexString generates hex state address from namespace and key

func GetStateHashFromStringKey

func GetStateHashFromStringKey(familyName, key string) []byte

GetStateHashFromStringKey generate 35 bytes length state hash from string based key

func GetStateHashFromUint64Key

func GetStateHashFromUint64Key(familyName string, key uint64) []byte

GetStateHashFromUint64Key generate 35 bytes length state hash from uint64 based key

func SplitStateAddress

func SplitStateAddress(address []byte) ([]byte, []byte)

SplitStateAddress splits state address to namespace and key

func SplitStateAddressHexString

func SplitStateAddressHexString(stateAddressHexString string) ([]byte, []byte)

SplitStateAddressHexString splits state address hex string to namespace and key

func StateAddressByteSliceToHexString

func StateAddressByteSliceToHexString(address []byte) string

StateAddressByteSliceToHexString converts byte slice to hex string

func StateAddressHexStringToByteSlice

func StateAddressHexStringToByteSlice(address string) []byte

StateAddressHexStringToByteSlice converts hex address string to byte slice

func Uint64ToByteSlice

func Uint64ToByteSlice(u uint64) []byte

Uint64ToByteSlice converts uint64 to byte slice

Types

type Argon2PasswordHashAlgorithm

type Argon2PasswordHashAlgorithm struct {
	// Defines the amount of computation time, given in number of iterations.
	Time uint32
	// Defines the memory usage (KiB).
	Memory uint32
	// Defines the number of parallel threads.
	Threads uint8
	// Defines the length of the hash in bytes.
	Length uint32
}

Argon2PasswordHashAlgorithm implements Argon2i password hashing algorithm.

func NewArgon2PasswordHashAlgorithm

func NewArgon2PasswordHashAlgorithm() *Argon2PasswordHashAlgorithm

NewArgon2PasswordHashAlgorithm secures password hashing using the argon2 algorithm.

func (*Argon2PasswordHashAlgorithm) Algorithm

func (h *Argon2PasswordHashAlgorithm) Algorithm() string

func (*Argon2PasswordHashAlgorithm) Encode

func (h *Argon2PasswordHashAlgorithm) Encode(password string, salt string) (string, error)

Encode turns a plain-text password into a hash.

func (*Argon2PasswordHashAlgorithm) Verify

func (h *Argon2PasswordHashAlgorithm) Verify(password string, encoded string) (bool, error)

Verify if a plain-text password matches the encoded digest.

type PasswordHashAlgorithmFactory

type PasswordHashAlgorithmFactory struct {
	// contains filtered or unexported fields
}

func DefaultPasswordHashAlgorithmFactory

func DefaultPasswordHashAlgorithmFactory() *PasswordHashAlgorithmFactory

func NewPasswordHashAlgorithmFactory

func NewPasswordHashAlgorithmFactory() *PasswordHashAlgorithmFactory

func (*PasswordHashAlgorithmFactory) AppendPasswordHashAlgorithm

func (p *PasswordHashAlgorithmFactory) AppendPasswordHashAlgorithm(pha iface.IPasswordHashAlgorithm)

func (*PasswordHashAlgorithmFactory) CheckPassword

func (p *PasswordHashAlgorithmFactory) CheckPassword(password, encoded string) (bool, error)

func (*PasswordHashAlgorithmFactory) IsAlgorithmAvailable

func (p *PasswordHashAlgorithmFactory) IsAlgorithmAvailable(algorithm string) bool

func (*PasswordHashAlgorithmFactory) MakePassword

func (p *PasswordHashAlgorithmFactory) MakePassword(password, salt, algorithm string) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL