secure

package
v0.0.0-...-ddfd2c2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IdArgon2id = "argon2id"
	IdBcrypt   = "bcrypt"
	IdPBKDF2   = "pbkdf2"
)

Variables

View Source
var Argon2idPHC = &PHC{
	Id: IdArgon2id,
	Params: map[string]interface{}{
		"m": 65536,
		"t": 3,
		"p": 2,
	},
}
View Source
var BcryptPHC = &PHC{
	Id: IdBcrypt,
	Params: map[string]interface{}{
		"r": 10,
	},
}
View Source
var PBKDF2PHC = &PHC{
	Id: IdPBKDF2,
	Params: map[string]interface{}{
		"t": 310_000,
		"h": "sha256",
	},
}

Functions

func IsIdSupported

func IsIdSupported(id string) bool

func LoadConfig

func LoadConfig(path string) error

Load secure configuration from file

func RandomBytes

func RandomBytes(len uint32) ([]byte, error)

RandomBytes generate secure random bytes

func SetDefaultPHC

func SetDefaultPHC(id string)

Types

type PHC

type PHC struct {
	Id      string
	Version int
	Params  map[string]interface{}
	Salt    string
	Value   string
}

Password Hashing Competition

func DefaultPHC

func DefaultPHC() *PHC

func (*PHC) Hash

func (p *PHC) Hash(password string) (string, error)

Hash password

func (*PHC) String

func (p *PHC) String() string

func (*PHC) Verify

func (p *PHC) Verify(password string) error

Verify password

type SConfiguration

type SConfiguration struct {
	PCHID string `yaml:"pchid"` // Password hash algorithm
}

Jump to

Keyboard shortcuts

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