crypto: golang.org/x/crypto/nacl/secretbox Index | Files

package secretbox

import "golang.org/x/crypto/nacl/secretbox"

Package secretbox encrypts and authenticates small messages.

Secretbox uses XSalsa20 and Poly1305 to encrypt and authenticate messages with secret-key cryptography. The length of messages is not hidden.

It is the caller's responsibility to ensure the uniqueness of nonces—for example, by using nonce 1 for the first message, nonce 2 for the second message, etc. Nonces are long enough that randomly generated nonces have negligible risk of collision.

This package is interoperable with NaCl: http://nacl.cr.yp.to/secretbox.html.

Index

Package Files

secretbox.go

Constants

const Overhead = poly1305.TagSize

Overhead is the number of bytes of overhead when boxing a message.

func Open

func Open(out []byte, box []byte, nonce *[24]byte, key *[32]byte) ([]byte, bool)

Open authenticates and decrypts a box produced by Seal and appends the message to out, which must not overlap box. The output will be Overhead bytes smaller than box.

func Seal

func Seal(out, message []byte, nonce *[24]byte, key *[32]byte) []byte

Seal appends an encrypted and authenticated copy of message to out, which must not overlap message. The key and nonce pair must be unique for each distinct message and the output will be Overhead bytes longer than message.

Package secretbox imports 2 packages (graph) and is imported by 93 packages. Updated about 10 hours ago. Refresh now. Tools for package owners.