encryption

package
v0.0.0-...-1ab3394 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHash         = errors.New("the encoded hash is not in the correct format")
	ErrIncompatibleVersion = errors.New("incompatible version of argon2")
)
View Source
var JwtSecretKey = ""

Functions

func Base64Decode

func Base64Decode(encodedData string) (string, error)

func Base64Encode

func Base64Encode(data string) string

func ComparePasswordAndHash

func ComparePasswordAndHash(password, encodedHash string) (match bool, err error)

Check if the password is match the hashed password

func GenerateID

func GenerateID() uint64

Generate new snowflake ID

func GenerateNewJwtToken

func GenerateNewJwtToken(id uint64, credentials []string, expiresAt time.Time) (string, error)

Generate new jwt token with credentials

func GenerateRandomBase64String

func GenerateRandomBase64String(bits int) (string, error)

Generate random base64 string

func HashPassword

func HashPassword(password string) (string, error)

Hash passsword with argon2i

func ParseAndValidateJWT

func ParseAndValidateJWT(tokenString string) (jwt.MapClaims, error)

ParseAndValidateJWT parses and validates the JWT, returning the claims and any error

func RandStringRunes

func RandStringRunes(n int, urlSafe bool) (string, error)

Generate random string this can provide 88^n possible

Types

This section is empty.

Jump to

Keyboard shortcuts

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