Documentation ¶
Index ¶
- Variables
- func IsWrongPassword(err error) bool
- func Marshal(v interface{}, options *Options) ([]byte, error)
- func MarshalToFile(file string, v interface{}, options *Options) error
- func StaticKey(key []byte) func() ([]byte, error)
- func Unmarshal(data []byte, v interface{}, options *Options) error
- func UnmarshalFromFile(file string, v interface{}, options *Options) error
- type KeySource
- type Options
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrChecksumMismatch is returned when the checksum of a decrypted value is wrong indicating a wrong password. ErrChecksumMismatch = fmt.Errorf("checksum mismatch") )
Functions ¶
func IsWrongPassword ¶
IsWrongPassword returns whether the given error indicates a wrong password.
func Marshal ¶
Marshal returns a json representation of v and replaces all jcrypt-annotated fields with encrypted values.
func MarshalToFile ¶
MarshalToFile marshals an object and writes the data to a file using os.ModePerm.
func StaticKey ¶
StaticKey returns a KeySource to be used for Options.GetKeyHandler that simply returns a fixed key.
func UnmarshalFromFile ¶
UnmarshalFromFile reads a file and unmarshals it.
Types ¶
type KeySource ¶
KeySource defines a handler function to obtain the encryption passphrase. This handler is only called if a passphrase is required.
type Options ¶
type Options struct { // Salt defines a salt for pbkdf2 key derivation Salt []byte // GetKeyHandler is called when a key is required for marshalling or unmarshalling. Is called at most once for every operation. GetKeyHandler KeySource // YAML can be set to true to output or process YAML encoding instead of JSON. YAML bool }
Options define further parameters for marshalling and crypto operations.
Click to show internal directories.
Click to hide internal directories.