cryptography

package
v0.0.0-...-6e75e83 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessToken = iota
	RefreshToken
)
View Source
const (
	UUID = iota + 1
)

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(hashedPassword, password string) (isPasswordValid bool)

func HashPassword

func HashPassword(password string) (hashedPassword string, err error)

Types

type Generator

type Generator interface {
	fmt.Stringer
	Bytes() []byte
}

type Hash

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

func NewHash

func NewHash(uuid Generator) *Hash

func (*Hash) GenHash

func (h *Hash) GenHash(in []byte, kind int) []byte

func (*Hash) GenHashString

func (h *Hash) GenHashString(in []byte, kind int) string

type Hasher

type Hasher interface {
	GenHashString(in []byte, kind int) string
	GenHash(in []byte, kind int) []byte
}

type TokenJWT

type TokenJWT struct {
	AccessSecret  []byte
	RefreshSecret []byte
}

func (*TokenJWT) CreateToken

func (o *TokenJWT) CreateToken(userID string, ttl time.Duration, kind int) (string, error)

CreateToken create new token with parameters.

func (*TokenJWT) ParseToken

func (o *TokenJWT) ParseToken(inputToken string, kind int) (UserClaims, error)

ParseToken parsing input token, and return email and role from token.

type TokenManager

type TokenManager interface {
	CreateToken(userID string, ttl time.Duration, kind int) (string, error)
	ParseToken(inputToken string, kind int) (UserClaims, error)
}

func NewTokenJWT

func NewTokenJWT(token *config.Token) TokenManager

type UUIDGenerator

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

func NewUUIDGenerator

func NewUUIDGenerator() *UUIDGenerator

func (*UUIDGenerator) Bytes

func (u *UUIDGenerator) Bytes() []byte

func (*UUIDGenerator) String

func (u *UUIDGenerator) String() string

type UserClaims

type UserClaims struct {
	ID string `json:"uid"`
	jwt.RegisteredClaims
}

UserClaims include custom claims on jwt.

type UserFromClaims

type UserFromClaims struct {
	ID int
}

Jump to

Keyboard shortcuts

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