duck.utils.safe_compare

Module for safer comparison of sensitive information without having to worry about timing attacks

Module Contents

Functions

constant_time_compare

This is a constant time comparison function with a sense of avoiding timing attacks, meaning, nomatter how short or long the 2 strings are, the time of comparing any kind of string is the same (constant), hence tackling timing attacks.

API

duck.utils.safe_compare.constant_time_compare(str_a: str, str_b: str)[source]

This is a constant time comparison function with a sense of avoiding timing attacks, meaning, nomatter how short or long the 2 strings are, the time of comparing any kind of string is the same (constant), hence tackling timing attacks.