MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / Put

Method Put

certcache/cryptobox.go:52–63  ·  view source on GitHub ↗
(ctx context.Context, key string, data []byte)

Source from the content-addressed store, hash-verified

50}
51
52func (c *EncryptedCache) Put(ctx context.Context, key string, data []byte) error {
53 // Select a random nonce, and leave capacity for the ciphertext.
54 nonce := make([]byte, c.aead.NonceSize(), c.aead.NonceSize()+len(data)+c.aead.Overhead())
55 if _, err := cryptorand.Read(nonce); err != nil {
56 return err
57 }
58
59 // Encrypt the message and append the ciphertext to the nonce.
60 encryptedData := c.aead.Seal(nonce, nonce, data, []byte(key))
61
62 return c.next.Put(ctx, key, encryptedData)
63}
64
65func (c *EncryptedCache) Delete(ctx context.Context, key string) error {
66 return c.next.Delete(ctx, key)

Callers

nothing calls this directly

Calls 1

ReadMethod · 0.45

Tested by

no test coverage detected