Documentation ¶
Overview ¶
Package age provides a wrapper for "gopkg.in/yaml.v3" to decrypt age encrypted data when Unmarshalling and encrypting data when Marshalling.
Decoding ¶
See https://github.com/sylr/go-yaml-crypto/blob/master/age/examples/decode.go
Encoding ¶
See https://github.com/sylr/go-yaml-crypto/blob/master/age/examples/encode.go
Index ¶
Constants ¶
const (
// YAMLTag tag that is used to identify data to crypt/decrypt
YAMLTag = "!crypto/age"
)
Variables ¶
This section is empty.
Functions ¶
func MarshalYAML ¶
MarshalYAML takes a *yaml.Node and []age.Recipient and recursively encrypt/marshal the Values.
Types ¶
type ArmoredString ¶
ArmoredString is a struct holding the string to encrypt and the intended recipients.
func (ArmoredString) MarshalYAML ¶
func (a ArmoredString) MarshalYAML() (interface{}, error)
MarshalYAML encrypts the ArmoredString and marshals it to YAML. If Recipients is empty then the Value is kept unencrypted.
func (*ArmoredString) String ¶
func (a *ArmoredString) String() string
String implements the Stringer interface.
func (*ArmoredString) UnmarshalYAML ¶
func (a *ArmoredString) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML pushes the yaml.Node.Value in the ArmoredString.Value.
type Wrapper ¶
type Wrapper struct { // Value holds the struct that will be decrypted with the Identities. Value interface{} // Identities that will be used for decrypting. Identities []age.Identity }
Wrapper is a struct that allows to decrypt crypted armored data in YAML as long that the data is tagged with "!crypto/age".
database_login: mylogin database_password: !crypto/age | -----BEGIN AGE ENCRYPTED FILE----- ... ... -----END AGE ENCRYPTED FILE-----
Example:
bytes := []byte(...) node := struct { Key1 string `yaml:"key1"` Key2 string `yaml:"key2"` }{} w := Wrapper{ Value: &node, Identities: []age.Indentity{...}, } decoder := yaml.NewDecoder(in) err := decoder.Decode(&w)
If you intend to only display the YAML data with unencryted values you should use `&yaml.Node{}` as `Wrapper.Value` so you can marshal it later with comments.
func (Wrapper) UnmarshalYAML ¶
UnmarshalYAML takes yaml.Node and recursively decrypt data marked with the !crypto/age YAML tag.