sodium_memcmp

Constant-time test for equality

WARNING: sodium_memcmp() must be used to verify if two secret keys are equal, in constant time (if array's length are equal). If array's length are NOT equal, the decision is solely based on that, i.e. no constant time guarantee and the function returns false. This function is not designed for lexicographical comparisons. Preferably use this function with equal length arrays.

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

Return Value

Type: bool

true if the keys are equal, and false if they differ.

See Also

Meta