Function constant_time_eq::constant_time_eq [−][src]
pub fn constant_time_eq(a: &[u8], b: &[u8]) -> bool
Compares two equal-sized byte strings in constant time.
Examples
use constant_time_eq::constant_time_eq; assert!(constant_time_eq(b"foo", b"foo")); assert!(!constant_time_eq(b"foo", b"bar")); assert!(!constant_time_eq(b"bar", b"baz")); // Not equal-sized, so won't take constant time. assert!(!constant_time_eq(b"foo", b"")); assert!(!constant_time_eq(b"foo", b"quux"));