utils

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Utils

type Utils struct {
	// contains filtered or unexported fields
}

Utils is a utility structure that holds the AES key.

func NewUtils

func NewUtils() (*Utils, error)

NewUtils creates a new Utils instance with the AES key from the environment variable. The AES key must be exactly 32 bytes (256 bits) long.

func (*Utils) Decrypt

func (u *Utils) Decrypt(data string) ([]byte, error)

Decrypt decrypts the given base64 encoded data using AES encryption in CTR mode. The IV is extracted from the ciphertext and used to initialize the cipher.

func (*Utils) Encrypt

func (u *Utils) Encrypt(data []byte) (string, error)

Encrypt encrypts the given data using AES encryption in CTR mode. A random Initialization Vector (IV) is generated for each encryption operation. The IV is prepended to the ciphertext and base64 encoded.

Jump to

Keyboard shortcuts

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