stream

package
v0.0.0-...-cd9060f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const NonceSize = 24

Variables

This section is empty.

Functions

func Stream

func Stream(l int, nonce nacl.Nonce, key nacl.Key) []byte

Stream produces a l-byte stream as a function of a secret key k and a nonce n. Note that 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.

func XOR

func XOR(message []byte, nonce nacl.Nonce, key nacl.Key) []byte

XOR encrypts a message m using a secret key k and a nonce n. XOR returns the ciphertext c. Note that 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.

Note also that encrypting a message with XOR does not protect against that message being tampered with in transit. To detect tampering, combine encryption with an authenticator, like the one provided by nacl/secretbox.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL