Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Encrypt ¶
Encrypt retruns the encrypted byte array of v. Before encrypting, Encrypt serializes v as json
Example ¶
package main import ( "bytes" "log" secret "github.com/nasa9084/go-secret" ) func main() { // a config including sensitive data type Config struct { ID string Password string } cfg := Config{ ID: "somethingID", Password: "somethingPassword", } masterPassword := "qwerty" var buf bytes.Buffer // you can use Encrypter like json.Encoder if err := secret.NewEncrypter(&buf).Encrypt(cfg, masterPassword); err != nil { log.Fatal(err) } // now buf contains encrypted data }
Output:
Types ¶
type Decrypter ¶
type Decrypter struct {
// contains filtered or unexported fields
}
Decrypter reads and decrypt from an input stream.
func NewDecrypter ¶
NewDecrypter returns a new decrypter that reads from r.
type Encrypter ¶
type Encrypter struct {
// contains filtered or unexported fields
}
An Encrypter writes encrypted values to an output stream.
func NewEncrypter ¶
NewEncrypter returns a new encrypter that writes to w.
Click to show internal directories.
Click to hide internal directories.