models

package
v0.0.0-...-7fb6363 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PasswordHash

type PasswordHash struct {
	// The Hash and salt.
	Hash []byte
}

A PasswordHash stores a hashed and salted password.

func NewPasswordHash

func NewPasswordHash(password string, cost int) (*PasswordHash, error)

NewPasswordHash hashes and salts a plaintext password with the specified cost.

See golang.org/x/crypto/bcrypt.DefaultCost, golang.org/x/crypto/bcrypt.MinCost and golang.org/x/crypto/bcrypt.MaxCost for the possible values for cost.

func (*PasswordHash) Compare

func (p *PasswordHash) Compare(password string) error

Compare compares the password hash against a plaintext password.

Returns nil if the password matches, or an error otherwise.

func (*PasswordHash) MarshalJSON

func (p *PasswordHash) MarshalJSON() ([]byte, error)

MarshalJSON encodes the password hash as a quoted string.

func (*PasswordHash) UnmarshalJSON

func (p *PasswordHash) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes the password hash from a quoted string.

type Task

type Task struct {
	ID          uint64
	Description string
}

type User

type User struct {
	ID       uint64
	Email    string
	Password *PasswordHash
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳