OxL Reference

fn constantTimeEq

Compares two byte strings in time that does not depend on where they differ (different lengths are unequal at once).

Example:

oxl✓ checked in CI
use std.crypto { constantTimeEq }
use std.ser { bytesOf }

fn main() io {
  print("{constantTimeEq(bytesOf(&"a"), bytesOf(&"a"))} {constantTimeEq(bytesOf(&"a"), bytesOf(&"b"))}")
}
Output
true false
pub(api) fn constantTimeEq(a: bytes, b: bytes) -> bool

Since. 1.0.0-beta

Parameters

NameType
abytes
bbytes

Returns

bool

Effects

none declared (pure unless the body says otherwise)

Defined in: std/crypto/crypto.oxl:316

See also