Documentation ¶
Overview ¶
Package ejson implements the primary interface to interact with ejson documents and keypairs. The CLI implemented by cmd/ejson is a fairly thin wrapper around this package.
Index ¶
- func Decrypt(in io.Reader, out io.Writer, keydir string, userSuppliedPrivateKey string) error
- func DecryptFile(filePath, keydir string, userSuppliedPrivateKey string) ([]byte, error)
- func Encrypt(in io.Reader, out io.Writer) (int, error)
- func EncryptFileInPlace(filePath string) (int, error)
- func GenerateKeypair() (pub string, priv string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
Decrypt reads an ejson stream from 'in' and writes the decrypted data to 'out'. The private key is expected to be under 'keydir'. Returns error upon failure, or nil on success.
func DecryptFile ¶
DecryptFile takes a path to an encrypted EJSON file and returns the data decrypted. The public key used to encrypt the values is embedded in the referenced document, and the matching private key is searched for in keydir. There must exist a file in keydir whose name is the public key from the EJSON document, and whose contents are the corresponding private key. See README.md for more details on this.
func Encrypt ¶
Encrypt reads all contents from 'in', extracts the pubkey and performs the requested encryption operation, writing the resulting data to 'out'. Returns the number of bytes written and any error that might have occurred.
func EncryptFileInPlace ¶
EncryptFileInPlace takes a path to a file on disk, which must be a valid EJSON file (see README.md for more on what constitutes a valid EJSON file). Any encryptable-but-unencrypted fields in the file will be encrypted using the public key embdded in the file, and the resulting text will be written over the file present on disk.
func GenerateKeypair ¶
GenerateKeypair is used to create a new ejson keypair. It returns the keys as hex-encoded strings, suitable for printing to the screen. hex.DecodeString can be used to load the true representation if necessary.
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package crypto implements a simple convenience wrapper around golang.org/x/crypto/nacl/box.
|
Package crypto implements a simple convenience wrapper around golang.org/x/crypto/nacl/box. |
Package json implements functions to load the Public key data from an EJSON file, and to walk that data file, encrypting or decrypting any keys which, according to the specification, are marked as encryptable (see README.md for details).
|
Package json implements functions to load the Public key data from an EJSON file, and to walk that data file, encrypting or decrypting any keys which, according to the specification, are marked as encryptable (see README.md for details). |