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

Method Decrypt

secrets/secrets.go:117–132  ·  view source on GitHub ↗

Decrypt decrypts the ciphertext and returns the plaintext.

(ctx context.Context, ciphertext []byte)

Source from the content-addressed store, hash-verified

115
116// Decrypt decrypts the ciphertext and returns the plaintext.
117func (k *Keeper) Decrypt(ctx context.Context, ciphertext []byte) (plaintext []byte, err error) {
118 ctx, span := k.tracer.Start(ctx, "Decrypt")
119 defer func() { k.tracer.End(ctx, span, err) }()
120
121 k.mu.RLock()
122 defer k.mu.RUnlock()
123 if k.closed {
124 return nil, errClosed
125 }
126
127 b, err := k.k.Decrypt(ctx, ciphertext)
128 if err != nil {
129 return nil, wrapError(k, err)
130 }
131 return b, nil
132}
133
134var errClosed = gcerr.Newf(gcerr.FailedPrecondition, nil, "secrets: Keeper has been closed")
135

Callers 5

TestErrorsAreWrappedFunction · 0.95
TestKeeperIsClosedFunction · 0.95
TestOpenTelemetryFunction · 0.95
ExampleFunction · 0.95
ExampleKeeper_DecryptFunction · 0.95

Calls 4

StartMethod · 0.80
EndMethod · 0.80
wrapErrorFunction · 0.70
DecryptMethod · 0.65

Tested by 5

TestErrorsAreWrappedFunction · 0.76
TestKeeperIsClosedFunction · 0.76
TestOpenTelemetryFunction · 0.76
ExampleFunction · 0.76
ExampleKeeper_DecryptFunction · 0.76