pub struct SecureComparison;
Expand description
Secure comparison utilities
Implementations§
Source§impl SecureComparison
impl SecureComparison
Sourcepub fn constant_time_eq(a: &str, b: &str) -> bool
pub fn constant_time_eq(a: &str, b: &str) -> bool
Constant-time string comparison
Sourcepub fn constant_time_eq_bytes(a: &[u8], b: &[u8]) -> bool
pub fn constant_time_eq_bytes(a: &[u8], b: &[u8]) -> bool
Constant-time byte comparison
Sourcepub fn secure_string_compare(a: &str, b: &str) -> bool
pub fn secure_string_compare(a: &str, b: &str) -> bool
Compare strings with timing attack protection This function always takes the same amount of time regardless of where differences occur
Sourcepub fn verify_token(provided: &str, expected: &str) -> bool
pub fn verify_token(provided: &str, expected: &str) -> bool
Verify that two tokens match using constant-time comparison
Auto Trait Implementations§
impl Freeze for SecureComparison
impl RefUnwindSafe for SecureComparison
impl Send for SecureComparison
impl Sync for SecureComparison
impl Unpin for SecureComparison
impl UnwindSafe for SecureComparison
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more