sodiumMemcmp Constant-time comparison function.
This function is not a lexicographic comparator and should be never used for this purpose. It should only be used when comparing two pieces of secret data, such as keys or authentication tags.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Modulelibsodium-bindings-0.0.1.1Haskell2010
These are bindings to some of libsodium's utils.h.
Included are Hex and Base64 encoding/decoding functions along with a constant-time memcmp for handling secret data.
sodiumMemcmp Constant-time comparison function.
This function is not a lexicographic comparator and should be never used for this purpose. It should only be used when comparing two pieces of secret data, such as keys or authentication tags.
sodiumBin2Hex :: CStringhex, The output buffer.
-> CSizehex_len, The maximum number of bytes this function is allowed to write
to the output buffer. Must be at least bin_len * 2 + 1 bytes long.
-> Ptr CUCharbin, The input buffer.
-> CSizebin_len, The length of the input buffer.
-> IO CStringThe return string, terminated with a null byte.
Encode bytes to a hexidecimal string. Constant-time.
sodiumBin2Base64 :: CStringb64, The output buffer.
-> CSizeb64_maxlen, The maximum length of the output buffer.
Choosing a correct size is not straightforward and depends on
the variant. The sodium_base64_ENCODED_LEN(BIN_LEN, VARIANT)
macro computes the minimum amount of bytes needed to encode BIN_LEN
bytes with a chosen VARIANT.
-> Ptr CUCharbin, The input buffer.
-> CSizebin_len, The length of the input buffer.
-> CIntvariant, Which Base64 variant to use. None of the variants provide
any encryption.
-> IO CStringThe returned Base64 string, terminated with a null byte.
Encode bytes to a Base64 string. Constant-time.
The original variant of Base64 with padding. This ensures that the length of the encoded data will always be a multiple of four bytes.
The original variant of Base64. No variant offers any security advantages over the other.
The URL-safe variant of Base64 with padding.