secure_compare

Function secure_compare 

Source
pub fn secure_compare(a: &[u8], b: &[u8]) -> bool
Expand description

Constant-time comparison of two byte slices.

Returns true if the slices are equal, false otherwise. The comparison time is constant regardless of where (or if) the slices differ.

ยงExample

use quantacore::utils::secure_compare;

assert!(secure_compare(b"hello", b"hello"));
assert!(!secure_compare(b"hello", b"world"));