mirror of
https://github.com/getsops/sops.git
synced 2026-02-05 12:45:21 +01:00
@@ -54,6 +54,9 @@ func parse(value string) (*encryptedValue, error) {
|
||||
|
||||
// Decrypt takes a sops-format value string and a key and returns the decrypted value and a stash value
|
||||
func (c Cipher) Decrypt(value string, key []byte, path string) (plaintext interface{}, stash interface{}, err error) {
|
||||
if value == "" {
|
||||
return "", nil, nil
|
||||
}
|
||||
encryptedValue, err := parse(value)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
@@ -100,6 +103,9 @@ func (c Cipher) Decrypt(value string, key []byte, path string) (plaintext interf
|
||||
|
||||
// Encrypt takes one of (string, int, float, bool) and encrypts it with the provided key and additional auth data, returning a sops-format encrypted string.
|
||||
func (c Cipher) Encrypt(value interface{}, key []byte, path string, stash interface{}) (string, error) {
|
||||
if value == "" {
|
||||
return "", nil
|
||||
}
|
||||
aescipher, err := cryptoaes.NewCipher(key)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Could not initialize AES GCM encryption cipher: %s", err)
|
||||
|
||||
@@ -33,9 +33,6 @@ func TestRoundtripString(t *testing.T) {
|
||||
f := func(x, aad string) bool {
|
||||
key := make([]byte, 32)
|
||||
rand.Read(key)
|
||||
if x == "" {
|
||||
return true
|
||||
}
|
||||
s, err := Cipher{}.Encrypt(x, key, aad, nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
||||
Reference in New Issue
Block a user