Skip to main content

Sometimes you need to test strings for equality with an algorithm whose timing depends only on the length of the strings, and not on the contents of the strings themselves. If one of those strings is of constant width – an HMAC, for example – then it becomes a constant-time operation. This can be used to prevent some timing side-channel attacks, such as the critical vulnerability found in KeyCzar back in 2009.

This module offers a single function, equals(x, y), which takes two strings x and y and returns True if they are equal, and False if they are not. The time this function takes does not depend on what specific bytes are in these strings. Strings are encoded with UTF-8 before being compared. This works on both Unicode and byte strings, in Python 2 and 3.

This works with Python 2 and 3, and PyPy. The license is Apache 2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streql-2.0.1.tar.gz (2.6 kB view details)

Uploaded Source

File details

Details for the file streql-2.0.1.tar.gz.

File metadata

  • Download URL: streql-2.0.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for streql-2.0.1.tar.gz
Algorithm Hash digest
SHA256 a050ea01a0461d45670b2c32b56e4d291fa00de8b97f0242edbcb335f245ccf3
MD5 2eda0c8c0a0480df0c67fb4caff38dd9
BLAKE2b-256 21f802069c0c754fd79efdad11604b9a471601f4882d7e2065d4b7f066058dd4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page