security

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(cipherText string, key string) ([]byte, error)

Decrypt decrypts encrypted text with key (must be valid 32 chars aes key).

func Encrypt

func Encrypt(data []byte, key string) (string, error)

Encrypt encrypts data with key (must be valid 32 char aes key).

func NewToken

func NewToken(payload jwt.MapClaims, signingKey string, secondsDuration int64) (string, error)

NewToken generates and returns new HS256 signed JWT token.

func ParseJWT

func ParseJWT(token string, verificationKey string) (jwt.MapClaims, error)

ParseJWT verifies and parses JWT token and returns its claims.

func ParseUnverifiedJWT

func ParseUnverifiedJWT(token string) (jwt.MapClaims, error)

ParseUnverifiedJWT parses JWT token and returns its claims but DOES NOT verify the signature.

func RandomString

func RandomString(length int) string

RandomString generates a random string with the specified length.

The generated string is cryptographically random and matches [A-Za-z0-9]+ (aka. it's transparent to URL-encoding).

func RandomStringWithAlphabet

func RandomStringWithAlphabet(length int, alphabet string) string

RandomStringWithAlphabet generates a cryptographically random string with the specified length and characters set.

func S256Challenge

func S256Challenge(code string) string

S256Challenge creates base64 encoded sha256 challenge string derived from code. The padding of the result base64 string is stripped per RFC 7636.

Types

This section is empty.

Jump to

Keyboard shortcuts

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