HydroSecretBox
This module contains functions for encryption and decryption. Probing is not yet supported.
Example:
(def context (Hydro.context "Examples"))
(def msg (Hydro.buf "Arbitrary data to encrypt"))
(let-do [key (HydroSecretBox.keygen)
cipher (Maybe.unsafe-from (HydroSecretBox.encrypt &msg 0
context &key))]
(println*
&(Maybe.apply (HydroSecretBox.decrypt &cipher 0 context &key)
(fn [b] (Hydro.unbuf &b)))))
decrypt
defn
(Fn [(Ref (Array Byte) a), Int, (Ptr CChar), (Ref (Array Byte) b)] (Maybe (Array Byte)))
(decrypt c id ctx key)
encrypts a cipher c
with the ID id
, using the context
ctx
and key key
.
encrypt
defn
(Fn [(Ref (Array Byte) a), Int, (Ptr CChar), (Ref (Array Byte) b)] (Maybe (Array Byte)))
(encrypt m id ctx key)
encrypts a message m
with the ID id
, using the context
ctx
and key key
.
keygen
defn
(Fn [] (Array Byte))
(keygen)
generates a key for use in encryption/decryption procedures.