crypto

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crypto

type Crypto struct {
	HashSecretKey    string
	EncryptSecretKey string
	Logger           libLog.Logger
	Cipher           cipher.AEAD
}

func (*Crypto) Decrypt

func (c *Crypto) Decrypt(encryptedText *string) (*string, error)

Decrypt a base64 encoded encrypted plaintext. The encrypted plain text must be prefixed with the random nonce used for encryption.

func (*Crypto) Encrypt

func (c *Crypto) Encrypt(plainText *string) (*string, error)

Encrypt a plaintext using AES-GCM, which requires a private 32 bytes key and a random 12 bytes nonce. It generates a base64 string with the encoded ciphertext.

func (*Crypto) GenerateHash

func (c *Crypto) GenerateHash(plaintext *string) string

GenerateHash using HMAC-SHA256

func (*Crypto) InitializeCipher

func (c *Crypto) InitializeCipher() error

InitializeCipher loads an AES-GCM block cipher for encryption/decryption

Jump to

Keyboard shortcuts

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