Function areStringsEqualInConstantTime

  • Performs a constant-time comparison of two strings to mitigate timing attacks (CWE-208).

    This function is designed to prevent timing attacks by ensuring that the time it takes to compare two strings does not depend on the contents of the strings themselves. It achieves this by comparing all characters up to the length of the longer string, treating out-of-bounds characters as zeros, and using bitwise operations to maintain constant time execution.

    Returns

    • Returns true if the strings are identical, false otherwise.

    Parameters

    • a: string

      The first string to compare.

    • b: string

      The second string to compare.

    Returns boolean

Generated using TypeDoc