crypt

package
v0.64.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey() (string, error)

GenerateKey generates a new random 32-byte encryption key and returns it as base64.

Types

type FieldEncrypt

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

FieldEncrypt provides AES-GCM encryption for sensitive fields.

func NewFieldEncrypt

func NewFieldEncrypt(base64Key string) (*FieldEncrypt, error)

NewFieldEncrypt creates a new FieldEncrypt with the given base64-encoded key. The key must be 32 bytes when decoded (for AES-256).

func (*FieldEncrypt) Decrypt

func (f *FieldEncrypt) Decrypt(ciphertext string) (string, error)

Decrypt decrypts the given base64-encoded ciphertext and returns the plaintext. Returns empty string for empty input.

func (*FieldEncrypt) Encrypt

func (f *FieldEncrypt) Encrypt(plaintext string) (string, error)

Encrypt encrypts the given plaintext and returns base64-encoded ciphertext. Returns empty string for empty input.

func (*FieldEncrypt) LegacyDecrypt added in v0.64.1

func (f *FieldEncrypt) LegacyDecrypt(ciphertext string) (string, error)

LegacyDecrypt decrypts ciphertext that was encrypted using AES-CBC with a static IV. Deprecated: This method is kept only for backward compatibility with existing encrypted data.

func (*FieldEncrypt) LegacyEncrypt added in v0.64.1

func (f *FieldEncrypt) LegacyEncrypt(plaintext string) string

LegacyEncrypt encrypts plaintext using AES-CBC with a static IV. Deprecated: Use Encrypt instead. This method is kept only for backward compatibility.

Jump to

Keyboard shortcuts

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