Documentation ¶
Index ¶
- func New(parent rangedb.Store, eventEncryptor crypto.EventEncryptor) *encryptedStore
- func NewDecryptingRecordIterator(parent rangedb.RecordIterator, eventEncryptor crypto.EventEncryptor) *decryptingRecordIterator
- func NewDecryptingRecordSubscriber(parent rangedb.RecordSubscriber, eventEncryptor crypto.EventEncryptor) *decryptingRecordSubscriber
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.
Click to show internal directories.
Click to hide internal directories.