testutils

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSimpleTestKMS

func NewSimpleTestKMS() config.KeyManagementService

NewSimpleTestKMS creates a new simple test KMS with a default key

func NewTestCrypto

func NewTestCrypto(t interface{}) (*encx.Crypto, error)

NewTestCrypto creates a simple Crypto instance for testing and examples If t is nil, creates a basic test crypto for examples/demos

Types

type SimpleTestKMS

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

SimpleTestKMS implements a basic in-memory KMS for testing and examples

func (*SimpleTestKMS) CreateKey

func (s *SimpleTestKMS) CreateKey(ctx context.Context, description string) (string, error)

CreateKey creates a new test key and returns its ID

func (*SimpleTestKMS) DecryptDEK

func (s *SimpleTestKMS) DecryptDEK(ctx context.Context, keyID string, ciphertext []byte) ([]byte, error)

DecryptDEK decrypts the DEK using AES-GCM

func (*SimpleTestKMS) EncryptDEK

func (s *SimpleTestKMS) EncryptDEK(ctx context.Context, keyID string, plaintext []byte) ([]byte, error)

EncryptDEK encrypts the DEK using AES-GCM

func (*SimpleTestKMS) GetKeyID

func (s *SimpleTestKMS) GetKeyID(ctx context.Context, alias string) (string, error)

GetKeyID returns a test key ID for the given alias

type User

type User struct {
	ID    int    `json:"id"`
	Email string `json:"email" encx:"encrypt,hash_basic"`
	Phone string `json:"phone" encx:"encrypt"`
	SSN   string `json:"ssn" encx:"hash_secure"`
	// Added a comment to change the file hash
	Name string `json:"name"`

	// Companion fields for encryption/hashing
	EmailEncrypted []byte `json:"email_encrypted" db:"email_encrypted"`
	EmailHash      string `json:"email_hash" db:"email_hash"`
	PhoneEncrypted []byte `json:"phone_encrypted" db:"phone_encrypted"`
	SSNHashSecure  string `json:"ssn_hash_secure" db:"ssn_hash_secure"`
}

User represents a user with encrypted fields

Jump to

Keyboard shortcuts

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