security

package
v0.0.0-...-94e8fae Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// A2IDtime is the number of iterations (or passes) over the memory used by the algorithm Argon2id
	A2IDtime = 3

	// A2IDmemory is the amount of memory used by the algorithm Argon2id
	A2IDmemory = 64 * 1024

	// A2IDthreads is the number of threads used by the algorithm Argon2id
	A2IDthreads = 4

	// A2IDkeyLen is the length of the generated key (or password hash) by the algorithm Argon2id. 16 bytes or more is recommended.
	A2IDkeyLen = 32

	// A2IDsaltLen is the length of the random salt used by the algorithm Argon2id. 16 bytes is recommended for password hashing.
	A2IDsaltLen = 16
)

Variables

This section is empty.

Functions

func ComparePassword

func ComparePassword(hashedPassword, password string) (match bool, err error)

ComparePassword is used to compare a user-inputted password to a hash to see if the password matches or not.

func ExtractClaims

func ExtractClaims(tokenString string, tokenSecretKey string) (jwt.MapClaims, error)

ExtractClaims extracts claims from given token

func ExtractToken

func ExtractToken(bearer string) (token string, err error)

ExtractToken checks and returns token part of input string

func GenerateJWT

func GenerateJWT(m map[string]interface{}, tokenExpireTime time.Duration, tokenSecretKey string) (tokenString string, err error)

GenerateJWT ...

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes

func GenerateRandomCode

func GenerateRandomCode(n int) (string, error)

GenerateRandomCode returns a securely generated random string that consists of numbers that has length of 2*n

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

GenerateRandomString returns a URL-safe, base64 encoded securely generated random string.

func GenerateRandomStringByPool

func GenerateRandomStringByPool(n int, pool string) (string, error)

GenerateRandomStringByPool returns a securely generated random string based on pool.

func HashPassword

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

HashPassword is used to generate a new password hash for storing and comparing at a later date.

Types

type TokenInfo

type TokenInfo struct {
	ID string
}

func ParseClaims

func ParseClaims(token string, secretKey string) (result TokenInfo, err error)

Jump to

Keyboard shortcuts

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