returns the encrypted text and the encryption key id used. The first key in the keyring is used for encryption. If the keyring is empty, the text is returned as is along with an empty key id.
(text []byte)
| 3907 | |
| 3908 | // returns the encrypted text and the encryption key id used. The first key in the keyring is used for encryption. If the keyring is empty, the text is returned as is along with an empty key id. |
| 3909 | func (c *connection) encrypt(text []byte) ([]byte, string, error) { |
| 3910 | if len(c.encKeyring) == 0 { |
| 3911 | return text, "", nil |
| 3912 | } |
| 3913 | // use the first key in the keyring for encryption |
| 3914 | encrypted, err := encrypt(text, c.encKeyring[0].Secret) |
| 3915 | if err != nil { |
| 3916 | return nil, "", err |
| 3917 | } |
| 3918 | return encrypted, c.encKeyring[0].ID, nil |
| 3919 | } |
| 3920 | |
| 3921 | // returns the decrypted text, using the encryption key id provided. If the key id is empty, the text is returned as is. |
| 3922 | func (c *connection) decrypt(text []byte, encKeyID string) ([]byte, error) { |
no test coverage detected