encryptedstore

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: BSD-3-Clause Imports: 3 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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(parent rangedb.Store, eventEncryptor crypto.EventEncryptor) *encryptedStore

New constructs an Encrypted Store that automatically encrypts/decrypts events for a decorated parent rangedb.Store.

Example (Automatically_encrypt_decrypt)
// Given
seededRandReader := rand.New(rand.NewSource(100))
aesEncryptor := aes.NewGCM()
aesEncryptor.SetRandReader(seededRandReader)
keyStore := inmemorykeystore.New()
eventEncryptor := eventencryptor.New(keyStore, aesEncryptor)
eventEncryptor.SetRandReader(seededRandReader)
event := &cryptotest.CustomerSignedUp{
	ID:     "fe65ac8d8c3a45e9b3cee407f10ee518",
	Name:   "John Doe",
	Email:  "john@example.com",
	Status: "active",
}
inMemoryStore := inmemorystore.New()
encryptedStore := encryptedstore.New(inMemoryStore, eventEncryptor)
encryptedStore.Bind(&cryptotest.CustomerSignedUp{})

ctx := context.Background()

// When
_, err := encryptedStore.Save(ctx, &rangedb.EventRecord{Event: event})
PrintError(err)

fmt.Println("Auto Decrypted Event:")
recordIterator := encryptedStore.Events(ctx, 0)
for recordIterator.Next() {
	PrintEvent(recordIterator.Record().Data.(rangedb.Event))
}

fmt.Println("Raw Encrypted Event:")
rawRecordIterator := inMemoryStore.Events(ctx, 0)
for rawRecordIterator.Next() {
	PrintEvent(rawRecordIterator.Record().Data.(rangedb.Event))
}
Output:
Auto Decrypted Event:
{
  "ID": "fe65ac8d8c3a45e9b3cee407f10ee518",
  "Name": "John Doe",
  "Email": "john@example.com",
  "Status": "active"
}
Raw Encrypted Event:
{
  "ID": "fe65ac8d8c3a45e9b3cee407f10ee518",
  "Name": "Lp5pGK8QGYw3NJyJVBsW49HESSf+NEraAQoBmpLXboZvsN/L",
  "Email": "o1H9t1BClYc5UcyUV+Roe3wz5gwRZRjgBI/xzwZs8ueQGQ5L8uGnbrTGrh8=",
  "Status": "active"
}

func NewDecryptingRecordIterator

func NewDecryptingRecordIterator(parent rangedb.RecordIterator, eventEncryptor crypto.EventEncryptor) *decryptingRecordIterator

NewDecryptingRecordIterator constructs a new rangedb.Record iterator that decrypts events

func NewDecryptingRecordSubscriber

func NewDecryptingRecordSubscriber(parent rangedb.RecordSubscriber, eventEncryptor crypto.EventEncryptor) *decryptingRecordSubscriber

NewDecryptingRecordSubscriber decrypts records on Accept

Types

This section is empty.

Jump to

Keyboard shortcuts

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