sops icon indicating copy to clipboard operation
sops copied to clipboard

Encrypt in a package and export method encrypt to be used in import "go.mozilla.org/sops/v3/encrypt"

Open skrese opened this issue 2 years ago • 4 comments

In Go projects where you need encrypting with sops it'd be nice to have a direct access to the method func encrypt(opts encryptOpts) (encryptedFile []byte, err error) in cmd/sops/encrypt.go. In that manner you could do something like:

import (
...
    "go.mozilla.org/sops/v3/encrypt"
...
)
...
encryptedFile, _ := encrypt.Encrypt(encrypt.EncryptOpts{
                        InputStore:        &yaml.Store{},
                        OutputStore:       &yaml.Store{},
                        InputBytes:        buffer,
                        Cipher:            aes.NewCipher(),
                        KeyServices:       svcs,
                        UnencryptedSuffix: "_unencrypted",
                        EncryptedSuffix:   "",
                        UnencryptedRegex:  "",
                        EncryptedRegex:    "",
                        KeyGroups:         groups,
                        GroupThreshold:    0,
                    })

skrese avatar Feb 04 '23 15:02 skrese