nacl/secretbox: add license header and package prefix
Name the example package "secretbox_test" so we use the public
interface for secretbox in examples. This way the code appears the
same way a user would have to type it.
Change-Id: I0487e39927ddae297ea45e09a3fa397779a8e21d
Reviewed-on: https://go-review.googlesource.com/28222
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/nacl/secretbox/example_test.go b/nacl/secretbox/example_test.go
index fc7482a..b25e663 100644
--- a/nacl/secretbox/example_test.go
+++ b/nacl/secretbox/example_test.go
@@ -1,10 +1,16 @@
-package secretbox
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package secretbox_test
import (
"crypto/rand"
"encoding/hex"
"fmt"
"io"
+
+ "golang.org/x/crypto/nacl/secretbox"
)
func Example() {
@@ -29,7 +35,7 @@
}
// This encrypts "hello world" and appends the result to the nonce.
- encrypted := Seal(nonce[:], []byte("hello world"), &nonce, &secretKey)
+ encrypted := secretbox.Seal(nonce[:], []byte("hello world"), &nonce, &secretKey)
// When you decrypt, you must use the same nonce and key you used to
// encrypt the message. One way to achieve this is to store the nonce
@@ -37,7 +43,7 @@
// 24 bytes of the encrypted text.
var decryptNonce [24]byte
copy(decryptNonce[:], encrypted[:24])
- decrypted, ok := Open([]byte{}, encrypted[24:], &decryptNonce, &secretKey)
+ decrypted, ok := secretbox.Open([]byte{}, encrypted[24:], &decryptNonce, &secretKey)
if !ok {
panic("decryption error")
}