func EncryptFileInPlace(filePath string) (int, error) {
	var fileMode os.FileMode
	if stat, err := os.Stat(filePath); err == nil {
		fileMode = stat.Mode()
	} else {
		return -1, err
	}
	file, err := os.Open(filePath)
	if err != nil {
		return -1, err
	}
	var outBuffer bytes.Buffer
	written, err := Encrypt(file, &outBuffer)
	if err != nil {
		return -1, err
	}
	if err = file.Close(); err != nil {
		return -1, err
	}
	if err := ioutil.WriteFile(filePath, outBuffer.Bytes(), fileMode); err != nil {
		return -1, err
	}
	return written, nil
}
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.
package ejson
import (
	"bytes"
	"encoding/hex"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
	"github.com/Shopify/ejson/crypto"
	"github.com/Shopify/ejson/json"
)
func GenerateKeypair() (pub string, priv string, err error) {
	var kp crypto.Keypair
	if err := kp.Generate(); err != nil {
		return "", "", err
	}
	return kp.PublicString(), kp.PrivateString(), nil
}
func Encrypt(in io.Reader, out io.Writer) (int, error) {
	data, err := ioutil.ReadAll(in)
	if err != nil {
		return -1, err
	}
	var myKP crypto.Keypair
	if err = myKP.Generate(); err != nil {
		return -1, err
	}
	pubkey, err := json.ExtractPublicKey(data)
	if err != nil {
		return -1, err
	}
	encrypter := myKP.Encrypter(pubkey)
	walker := json.Walker{
		Action: encrypter.Encrypt,
	}
	newdata, err := walker.Walk(data)
	if err != nil {
		return -1, err
	}
	return out.Write(newdata)
}