Hydro

The base hydrogen module. It includes functions for creating and handling hydrogen buffers.

=

defn

(Fn [(Ref (Array Byte) a), (Ref (Array Byte) b)] Bool)

                        (= a b)
                    

compares two (Array Byte) instances in constant time. Comparing the same reference will lead to a failed comparison, as per the hydrogen specs.

buf

defn

(Fn [(Ref String a)] (Array Byte))

                        (buf s)
                    

creates an (Array Byte) from a string.

context

defn

(Fn [(Ref String a)] (Ptr CChar))

                        (context s)
                    

creates a context from a string.

erase

defn

(Fn [(Ref (Array Byte) a)] ())

                        (erase b)
                    

erases the contents of a (Array Byte) securely.

from-hex

defn

(Fn [(Ref String a)] (Maybe (Array Byte)))

                        (from-hex s)
                    

parses a string of hex digit pairs into an (Array Byte), accepting both upper- and lowercase digits. Returns Nothing unless the whole string is a sequence of hex digit pairs; separators are not allowed. The empty string yields an empty array.

raw

external

(Fn [(Ref (Array Byte) a)] (Ptr Byte))

to-hex

defn

(Fn [(Ref (Array Byte) a)] String)

                        (to-hex b)
                    

renders an (Array Byte) as a string of lowercase hex digit pairs, in constant time. This is the counterpart to from-hex, and the recommended way of storing or printing keys, hashes and ciphertexts.

unbuf

defn

(Fn [(Ref (Array Byte) a)] String)

                        (unbuf a)
                    

creates a string from a (Array Byte).