sodium_compare

Comparing large numbers.

It is suitable for lexicographical comparisons, or to compare nonces and counters stored in little-endian format. However, it is slower than sodium_memcmp(). The comparison is done in constant time for a given length. The two numbers don't need to have the same length in bytes. If array's length are NOT equal, the decision may be based on that, i.e. no constant time guarantee. Preferably use this function with equal length arrays.

  1. alias sodium_compare = deimos.sodium.utils.sodium_compare
  2. int sodium_compare(ubyte[] b1_, ubyte[] b2_)
    pragma(inline, true) @nogc nothrow pure @trusted
    int
    sodium_compare
    (
    const ubyte[] b1_
    ,
    const ubyte[] b2_
    )

Return Value

Type: int

-1 if b1_ < b2_, 1 if b1_ > b2_ and 0 if b1_ == b2_

See Also

Meta