Helpers
Bindings for various helper functions. See the libsodium helpers docs for more information.
sodium_memcmp
var bool = sodium.sodium_memcmp(b1, b2)
Compares b1 with b2, in constant-time for b1.length.
b1must be abufferb2must be abufferand must beb1.lengthbytes
Returns true when equal, otherwise false.
sodium_compare
var direction = sodium.sodium_compare(b1, b2)
Compares b1 with b2, regarding either as little-endian encoded number.
b1must be abufferb2must be abufferand must beb1.lengthbytes
Returns 1, 0, or -1 on whether b1 is greater than, equal to, or less than b2. This is the same scheme as Array.prototype.sort expect.
sodium_add
sodium.sodium_add(a, b)
Adds b to a (wrapping), regarding either as little-endian encoded number, and writing the result into a.
amust be abufferbmust be abufferand must bea.lengthbytes
sodium_sub
sodium.sodium_sub(a, b)
Subtracts b from a (wrapping), regarding either as little-endian encoded number, and writing the result into a.
amust be abufferbmust be abufferand must bea.lengthbytes
sodium_increment
sodium.sodium_increment(buf)
Increments buf as a little-endian number. This operation is constant-time for the length of buf.
bufmust be abuffer
sodium_is_zero
var bool = sodium.sodium_is_zero(buf, len)
Tests whether buf is all zero for len bytes. This operation is constant-time for len.
lenmust be an integer at mostbuf.length
Returns true if all len bytes are zero, otherwise false.
