Encrypt encrypts the plaintext and returns the cipher message.
(ctx context.Context, plaintext []byte)
| 97 | |
| 98 | // Encrypt encrypts the plaintext and returns the cipher message. |
| 99 | func (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. |
| 117 | func (k *Keeper) Decrypt(ctx context.Context, ciphertext []byte) (plaintext []byte, err error) { |