password

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type Argon2id

type Argon2id struct {
	Time    uint32 `json:"time"`
	Memory  uint32 `json:"memory"`
	Threads uint8  `json:"threads"`
	KeyLen  uint32 `json:"key_len"`
	SaltLen uint32 `json:"salt_len"`
}

func (*Argon2id) CheckPassword

func (x *Argon2id) CheckPassword(pwd string, data *structpb.Struct) bool

func (*Argon2id) GenerateHash

func (x *Argon2id) GenerateHash(pwd string) (*structpb.Struct, error)

func (*Argon2id) Verify

func (x *Argon2id) Verify() error

type AuthenticateData

type AuthenticateData struct {
	Type     string    `json:"type"`
	Plain    *Plain    `json:"plain"`
	Argon2id *Argon2id `json:"argon2id"`
	Bcrypt   *Bcrypt   `json:"bcrypt"`
	Scrypt   *Scrypt   `json:"scrypt"`
}

func ParseData

func ParseData(val *authenticate.Authenticate) (*AuthenticateData, error)

func (*AuthenticateData) Password

func (a *AuthenticateData) Password() Password

type Bcrypt

type Bcrypt struct {
	Cost int `json:"cost"`
}

func (*Bcrypt) CheckPassword

func (x *Bcrypt) CheckPassword(pwd string, data *structpb.Struct) bool

func (*Bcrypt) GenerateHash

func (x *Bcrypt) GenerateHash(pwd string) (*structpb.Struct, error)

func (*Bcrypt) Verify

func (x *Bcrypt) Verify() error

type Password

type Password interface {
	GenerateHash(pwd string) (*structpb.Struct, error)
	CheckPassword(pwd string, data *structpb.Struct) bool

	Verify() error
}

type Plain

type Plain struct{}

func (*Plain) CheckPassword

func (*Plain) CheckPassword(pwd string, data *structpb.Struct) bool

func (*Plain) GenerateHash

func (*Plain) GenerateHash(pwd string) (*structpb.Struct, error)

func (*Plain) Verify

func (*Plain) Verify() error

type Scrypt

type Scrypt struct {
	N       int    `json:"n"`
	R       int    `json:"r"`
	P       int    `json:"p"`
	KeyLen  int    `json:"key_len"`
	SaltLen uint32 `json:"salt_len"`
}

func (*Scrypt) CheckPassword

func (x *Scrypt) CheckPassword(pwd string, data *structpb.Struct) bool

func (*Scrypt) GenerateHash

func (x *Scrypt) GenerateHash(pwd string) (*structpb.Struct, error)

func (*Scrypt) Verify

func (x *Scrypt) Verify() error

Jump to

Keyboard shortcuts

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