gpswd

package module
v0.0.0-...-4d5fd34 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: BSD-2-Clause Imports: 4 Imported by: 0

README

gpswd - Golang SQL Password Column

gpswd.Password implements interfaces sql.Scanner and driver.Valuer.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyPassword   = errors.New("empty passowrd")
	ErrNotYetEncrypted = errors.New("not yet encrypted")
	ErrMismatched      = errors.New("mismatched password")
)
View Source
var BeforeEncrypt = func(plain, salt []byte) ([]byte, error) {
	return append(plain, salt...), nil
}

BeforeEncrypt is called before encryption and concats plain passwords and salt

View Source
var HashCost = 12

HashCost is cost of generating password hash

Functions

This section is empty.

Types

type Password

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

Password

func NewPassword

func NewPassword(plain string, salt []byte) *Password

NewPassword returns Password

func (*Password) Compare

func (p *Password) Compare(passwd string, salt []byte) error

Compare compares with password and returns nil if matched

func (*Password) Encrypt

func (p *Password) Encrypt() error

Encrypt encrypts plain password

func (*Password) Encrypted

func (p *Password) Encrypted() bool

Encrypted returns true if encrypted

func (*Password) Scan

func (p *Password) Scan(value any) error

Scan is an implementation interface sql.Scanner

func (*Password) Value

func (p *Password) Value() (driver.Value, error)

Value is an implementation interface driver.Valuer

Jump to

Keyboard shortcuts

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