internal

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

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

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MyArgon2idOptions = NewArgon2idOptions(10, 50, 12)

Functions

func CreateTokenJWT

func CreateTokenJWT(username string) (string, error)

func Decrypt

func Decrypt(ciphertext []byte, key []byte) ([]byte, error)

Decrypt ciphertext using secret key (argon2id)

func Encrypt

func Encrypt(plaintext []byte, key []byte) ([]byte, error)

Encrypt plaintext (Secret message) using secret key (argon2id)

func Generate

func Generate(passphrase string, options *Argon2idOptions) (key, salt []byte, err error)

Generate secret key and salt (argon2id KDF) from passphrase and options.

func NewHash

func NewHash(passphrase string, options *Argon2idOptions) (hash string, err error)

Create an argon2id string representation from secret key, salt and options

func VerifyTokenJWT

func VerifyTokenJWT(tokenStr string) (*jwt.Token, error)

Types

type Argon2idOptions

type Argon2idOptions struct {
	Iterations  uint32
	Memory      uint32
	Parallelism uint8
}

func Compare

func Compare(passphrase string, hash string) (bool, *Argon2idOptions, error)

Compare passphrase and decoded hash

func Decode

func Decode(hash string) (key, salt []byte, options *Argon2idOptions, err error)

Decode argon2id hash and returns secret key, salt and options

func NewArgon2idOptions

func NewArgon2idOptions(iterations, mb uint32, parallel uint8) Argon2idOptions

type Password

type Password struct {
	Text          string
	Charset       string
	Length        int
	CharsetLength int
	Entropy       float64
	HasUpper      bool
	HasLower      bool
	HasDigit      bool
	HasSymbol     bool
}

func (*Password) NewRandomString

func (p *Password) NewRandomString() string

Generate random string based on charset

func (*Password) ToString

func (p *Password) ToString() string

Password struct string representation

Jump to

Keyboard shortcuts

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