Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Crypt ¶
type Crypt struct {
// contains filtered or unexported fields
}
func (Crypt) Save ¶
Example ¶
c := New(filepath.Join(os.TempDir(), "test-crypt.json"), "my-passphrase")
_ = c.Save([]byte("hello world"))
output, _ := c.Load()
fmt.Println(string(output))
Output: hello world
func (Crypt) Writer ¶
func (c Crypt) Writer() io.WriteCloser
Example ¶
type record struct {
Name string `json:"name"`
}
c := New(filepath.Join(os.TempDir(), "test-crypt.json"), "my-passphrase")
input := record{Name: "john doe"}
w := c.Writer()
// encrypt
_ = json.NewEncoder(w).Encode(input)
// write to file
_ = w.Close()
// read using io.Reader
var output record
_ = json.NewDecoder(c.Reader()).Decode(&output)
fmt.Println(output.Name)
Output: john doe
type ErrDecryptionFailed ¶
type ErrDecryptionFailed struct {
Err error
}
func (*ErrDecryptionFailed) Error ¶
func (e *ErrDecryptionFailed) Error() string
func (*ErrDecryptionFailed) Unwrap ¶
func (e *ErrDecryptionFailed) Unwrap() error
Click to show internal directories.
Click to hide internal directories.