util

package
v0.0.0-...-20a8e94 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToPublicKey

func BytesToPublicKey(pub []byte) (*rsa.PublicKey, error)

func ConvertValidationError

func ConvertValidationError(err validator.ValidationErrors) error

ConvertValidationError converts a validator.ValidationErrors object into a single error message. It extracts the invalid field names from the validation errors and concatenates them into a single string.

Parameters:

  • err: a validator.ValidationErrors object containing the validation errors.

Returns:

  • An error object with a formatted message listing the invalid fields.

func GenerateCertificate

func GenerateCertificate(privateKey any, publicKey any, expireAt time.Time, signatureAlgo x509.SignatureAlgorithm) ([]byte, error)

func GenerateECDSAKey

func GenerateECDSAKey(curve elliptic.Curve) (*ecdsa.PrivateKey, []byte, error)

func GenerateRSAKey

func GenerateRSAKey(bitSize int) (*rsa.PrivateKey, []byte, error)

func HashFileMD5

func HashFileMD5(file io.Reader) (string, error)

HashFileMD5 computes the MD5 hash of the content read from the provided io.Reader.

Parameters:

  • file: an io.Reader representing the file content to be hashed.

Returns:

  • A string representing the MD5 hash in hexadecimal format.
  • An error if there is any issue during hashing.

func RandomNumber

func RandomNumber(amount int) int

func RandomPassPhrase

func RandomPassPhrase(length int, concatSymbol string) (string, error)

func RandomSaltString

func RandomSaltString(size int) (string, error)

func RandomString

func RandomString(length int) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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