MCPcopy Index your code
hub / github.com/rilldata/rill / encrypt

Method encrypt

admin/database/postgres/postgres.go:3909–3919  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
3909func (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.
3922func (c *connection) decrypt(text []byte, encKeyID string) ([]byte, error) {

Callers 2

InsertMagicAuthTokenMethod · 0.95
UpsertProjectVariableMethod · 0.95

Calls 1

encryptFunction · 0.85

Tested by

no test coverage detected