Exemplo n.º 1
0
func Example() {
	dataToEncrypt := "I am something to keep secret."
	password := "******"

	// create a Boxer with default scrypt settings
	bxr := boxer.NewDefaultBoxer()

	// encrypt data
	ciphertext, err := bxr.Encrypt([]byte(dataToEncrypt), []byte(password))
	if err != nil {
		panic(err)
	}

	// decrypt it again
	plaintext, err := bxr.Decrypt(ciphertext, []byte(password))
	if err != nil {
		panic(err)
	}

	fmt.Println(plaintext)
}
Exemplo n.º 2
0
func Encrypt(input []byte) ([]byte, error) {
	return boxer.NewDefaultBoxer().Encrypt(input, config.Password())
}