ParseEncryptionKeyring parses a JSON string containing an array of EncryptionKey objects. If the provided string is empty, an empty keyring is returned. When using an empty keyring, columns will be read and written without applying encryption/decryption.
(keyring string)
| 1274 | // If the provided string is empty, an empty keyring is returned. |
| 1275 | // When using an empty keyring, columns will be read and written without applying encryption/decryption. |
| 1276 | func ParseEncryptionKeyring(keyring string) ([]*EncryptionKey, error) { |
| 1277 | if keyring == "" { |
| 1278 | return nil, nil |
| 1279 | } |
| 1280 | |
| 1281 | var encKeyring []*EncryptionKey |
| 1282 | err := json.Unmarshal([]byte(keyring), &encKeyring) |
| 1283 | if err != nil { |
| 1284 | return nil, err |
| 1285 | } |
| 1286 | |
| 1287 | return encKeyring, nil |
| 1288 | } |
| 1289 | |
| 1290 | func NewRandomKeyring() ([]*EncryptionKey, error) { |
| 1291 | secret := make([]byte, 32) // 32 bytes for AES-256 |