Symmetric Encryption

Index

secretbox/context-bytes secretbox/decrypt secretbox/encrypt secretbox/header-bytes secretbox/key-bytes secretbox/keygen secretbox/probe-bytes secretbox/probe-create secretbox/probe-verify

Reference

Number of bytes in a context for secretbox functions.

(secretbox/decrypt cipher-text msg-id ctx key &opt buf)

Decrypt a cipher text that was produced with secretbox/encrypt. msg-id, ctx, and key must be the same as those used to encrypt the message. An optional buffer can be used to contain the plain text, otherwise a new buffer is created. Returns a buffer containing the plain text.

(secretbox/encrypt msg msg-id ctx key &opt buf)

Encrypt a message with a secretbox key and return the cipher text in a buffer. Also requires a message id, which is an integer, and a ctx, which is a non-secret byte-sequence. Lastly, requires a secret symmetric key for encryption. An optional buffer will prevent Janet from creating a new buffer, and instead append to and return the provided buffer.

Number of bytes in the header of an encrypted message.

Number of bytes in a secretbox key.

(secretbox/keygen)

Generate a key suitable for secretbox. The returned key is a 32 byte buffer.

Number of bytes in a secretbox probe.

(secretbox/probe-create cipher-text ctx key)

Create a probe for some cipher text created by secretbox/encrypt. The resulting probe is a constant length string that can be used to verify if cipher text is valid before decrypting the entire text. Returns a string.

(secretbox/probe-verify probe cipher-text ctx key)

Use a probe produced by secretbox/probe-create to check if some cipher text is genuine. If the cipher text is not forged or tampered with, returns true, otherwise false. Genuine cipher text can then be decrypted. Returns a boolean.