crypto

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeySize is the size of the key in bytes (AES-256)
	KeySize = 32
	// SaltSize is the size of the salt in bytes
	SaltSize = 16
	// Iterations is the number of iterations for PBKDF2
	Iterations = 100000
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(encryptedString string, key []byte) ([]byte, error)

Decrypt decrypts a base64 encoded string using AES-GCM.

func DeriveKey

func DeriveKey(password string, salt []byte) ([]byte, []byte, error)

DeriveKey derives a 32-byte key from a password and salt using PBKDF2. If salt is nil, a new random salt is generated. Returns the key and the salt used.

func Encrypt

func Encrypt(plaintext []byte, key []byte) (string, error)

Encrypt encrypts data using AES-GCM. Returns base64 encoded string containing nonce and ciphertext.

func GenerateRandomBytes

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

GenerateRandomBytes returns n random bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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