crypto

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCiphertextTooShort       = errors.New("ciphertext too short")
	ErrEncryptionKeyUnavailable = errors.New("NEXSS_CRYPTO_KEY is not configured")
	ErrInvalidEncryptionKey     = errors.New("NEXSS_CRYPTO_KEY must encode exactly 32 bytes")
)
View Source
var ErrMasterKeyTooShort = errors.New("crypto: master key secret must be at least 16 bytes")

Functions

func DecryptString

func DecryptString(ciphertext string) (string, error)

DecryptString decrypts a Base64-encoded value produced by EncryptString.

func EncryptString

func EncryptString(plaintext string) (string, error)

EncryptString encrypts a plaintext string with AES-256-GCM and returns a Base64-encoded nonce and ciphertext. Set NEXSS_CRYPTO_KEY before use.

func Pseudonymize

func Pseudonymize(value, salt string) string

Pseudonymize generuje nieodwracalny, deterministyczny hash HMAC dla pól wyszukiwarkowych (np. NIP/Email). Pozwala na wyszukiwanie rekordów w bazie bez konieczności przechowywania odszyfrowanych danych osobowych.

Types

type Envelope

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

Envelope zapewnia szyfrowanie AES-256-GCM z unikalnym kluczem wywodzonym dla każdego najemcy.

func NewEnvelope

func NewEnvelope(masterKeySecret string) (*Envelope, error)

func (*Envelope) DecryptForTenant

func (e *Envelope) DecryptForTenant(tenantID string, ciphertext []byte) ([]byte, error)

DecryptForTenant odszyfrowuje dane przy użyciu klucza najemcy.

func (*Envelope) DeriveTenantKey

func (e *Envelope) DeriveTenantKey(tenantID string) []byte

DeriveTenantKey generuje unikalny, 256-bitowy klucz DEK (Data Encryption Key) dla danego najemcy.

func (*Envelope) EncryptForTenant

func (e *Envelope) EncryptForTenant(tenantID string, plaintext []byte) ([]byte, error)

EncryptForTenant szyfruje dane przy użyciu klucza izolowanego dla konkretnego najemcy.

Jump to

Keyboard shortcuts

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