MCPcopy Create free account
hub / github.com/google/go-cloud / Encrypt

Method Encrypt

secrets/secrets.go:99–114  ·  view source on GitHub ↗

Encrypt encrypts the plaintext and returns the cipher message.

(ctx context.Context, plaintext []byte)

Source from the content-addressed store, hash-verified

97
98// Encrypt encrypts the plaintext and returns the cipher message.
99func (k *Keeper) Encrypt(ctx context.Context, plaintext []byte) (ciphertext []byte, err error) {
100 ctx, span := k.tracer.Start(ctx, "Encrypt")
101 defer func() { k.tracer.End(ctx, span, err) }()
102
103 k.mu.RLock()
104 defer k.mu.RUnlock()
105 if k.closed {
106 return nil, errClosed
107 }
108
109 b, err := k.k.Encrypt(ctx, plaintext)
110 if err != nil {
111 return nil, wrapError(k, err)
112 }
113 return b, nil
114}
115
116// Decrypt decrypts the ciphertext and returns the plaintext.
117func (k *Keeper) Decrypt(ctx context.Context, ciphertext []byte) (plaintext []byte, err error) {

Callers 6

TestErrorsAreWrappedFunction · 0.95
TestKeeperIsClosedFunction · 0.95
TestOpenTelemetryFunction · 0.95
ExampleFunction · 0.95
ExampleKeeper_EncryptFunction · 0.95
TestDecryptDecoderFunction · 0.95

Calls 4

StartMethod · 0.80
EndMethod · 0.80
wrapErrorFunction · 0.70
EncryptMethod · 0.65

Tested by 6

TestErrorsAreWrappedFunction · 0.76
TestKeeperIsClosedFunction · 0.76
TestOpenTelemetryFunction · 0.76
ExampleFunction · 0.76
ExampleKeeper_EncryptFunction · 0.76
TestDecryptDecoderFunction · 0.76