Documentation ¶
Overview ¶
Package utils contain useful helper functions
Index ¶
- func AESDecrypt(encryptedString string, keyString string) (decryptedString string, err error)
- func AESEncrypt(stringToEncrypt string, keyString string) (encryptedString string, err error)
- func Bcrypt(body string) (string, error)
- func BcryptCompare(input, truth string) bool
- func CheckFileExists(path string) bool
- func GenerateJWT(data map[string]interface{}, secret string) (jwtString string, err error)
- func IsHex(s string) bool
- func MakeRequest(router *gin.Engine, method, endpoint string, body io.Reader, ...) *httptest.ResponseRecorder
- func Min(a, b int) int
- func MustAtoi(value string) int
- func RemoveAccessToken(ctx *gin.Context, secureCookie bool)
- func SHA256(body string) string
- func UniqueInts(values []int) []int
- func ValidateJWT(tokenString, secret string) (*jwt.Token, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AESDecrypt ¶
AESDecrypt decrypts using AES. keyString must be 128, 196 or 256 bits.
func AESEncrypt ¶
AESEncrypt encrypts using AES. keyString must be 128, 196 or 256 bits.
func BcryptCompare ¶
BcryptCompare takes an input and a truth digest and compares them
Use this instead of direct comparisons because this function is safe.
func CheckFileExists ¶
CheckFileExists takes a path string and returns true if it exists
func GenerateJWT ¶
GenerateJWT generates a JWT from map
func MakeRequest ¶
func MakeRequest(router *gin.Engine, method, endpoint string, body io.Reader, cookies ...*http.Cookie) *httptest.ResponseRecorder
MakeRequest runs a single request. This is used by test functions that run requests on the router
func RemoveAccessToken ¶
RemoveAccessToken deletes the user access token
func UniqueInts ¶
UniqueInts takes a slice of integers and returns a new slice without duplicates
Types ¶
This section is empty.