package sodium

  1. Overview
  2. Docs
type storage = Bytes.t
val of_key : secret key -> storage

of_key k converts k to storage. The result is key_size bytes long.

val to_key : storage -> secret key

to_key s converts s to a secret key.

  • raises Size_mismatch

    if s is not key_size bytes long

val of_nonce : nonce -> storage

of_nonce n converts n to storage. The result is nonce_size bytes long.

val to_nonce : storage -> nonce

to_nonce s converts s to a nonce.

  • raises Size_mismatch

    if s is not nonce_size bytes long

val secret_box : secret key -> storage -> nonce -> storage

secret_box k m n encrypts and authenticates a message m using a secret key k and a nonce n, and returns the resulting ciphertext.

val secret_box_open : secret key -> storage -> nonce -> storage

secret_box_open k c n verifies and decrypts a ciphertext c using a secret key k and a nonce n, and returns the resulting plaintext m.

  • raises Verification_failure

    if authenticity of message cannot be verified