security

package
v0.0.0-...-cfeb2ff Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package security is func library that implement security standard.

Package security is func library that implement security standard.

Package security is func library that implement security standard.

Package security is func library that implement security standard. # This manifest was generated by ymir. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateRangeValidation

func DateRangeValidation(fl validator.FieldLevel) bool

DateRangeValidation custom validator for `daterange` tag.

func DateValidation

func DateValidation(fl validator.FieldLevel) bool

DateValidation custom validator for `datetime` tag.

func DatetimeValidation

func DatetimeValidation(fl validator.FieldLevel) bool

DatetimeValidation custom validator for `date` tag.

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 GenID

func GenID() (string, error)

GenID returns random id with lexicographically sortable identifier.

func GenerateRandomBytes

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

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomEmail

func GenerateRandomEmail(n int) string

GenerateRandomEmail generates a random email.

func GenerateRandomInt

func GenerateRandomInt(max *big.Int) int64

GenerateRandomInt generates a random integer between min and max.

func GenerateRandomString

func GenerateRandomString(n int) string

GenerateRandomString generates a random string of length n.

func ParseDate

func ParseDate(dtStr string) time.Time

ParseDate return time.Time convert date string.

func ParseDatetime

func ParseDatetime(dtStr string) time.Time

ParseDatetime return time.Time convert datetime string.

func ParseDefault

func ParseDefault(fl validator.FieldLevel) bool

ParseDefault custom validator for `default` tag.

func ParseTags

func ParseTags(fl validator.FieldLevel) bool

ParseTags custom validator for `enum` tag.

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

type ErrorValidator

type ErrorValidator struct {
	Type    string `json:"error_type,omitempty"`
	Tag     string `json:"error_tag,omitempty"`
	Field   string `json:"error_field,omitempty"`
	Value   string `json:"error_value,omitempty"`
	Message string `json:"error_message,omitempty"`
}

ErrorValidator data struct error.

func Validate

func Validate(s any) (errors []ErrorValidator)

Validate returns ErrorValidator implements value validations for structs and individual fields based on tags.

Jump to

Keyboard shortcuts

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