__init__.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # -*- coding: utf-8 -*-
  2. #
  3. # ===================================================================
  4. # The contents of this file are dedicated to the public domain. To
  5. # the extent that dedication to the public domain is not available,
  6. # everyone is granted a worldwide, perpetual, royalty-free,
  7. # non-exclusive license to exercise all rights associated with the
  8. # contents of this file for any purpose whatsoever.
  9. # No rights are reserved.
  10. #
  11. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  12. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  14. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  15. # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  16. # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17. # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. # SOFTWARE.
  19. # ===================================================================
  20. """Hashing algorithms
  21. Hash functions take arbitrary binary strings as input, and produce a random-like output
  22. of fixed size that is dependent on the input; it should be practically infeasible
  23. to derive the original input data given only the hash function's
  24. output. In other words, the hash function is *one-way*.
  25. It should also not be practically feasible to find a second piece of data
  26. (a *second pre-image*) whose hash is the same as the original message
  27. (*weak collision resistance*).
  28. Finally, it should not be feasible to find two arbitrary messages with the
  29. same hash (*strong collision resistance*).
  30. The output of the hash function is called the *digest* of the input message.
  31. In general, the security of a hash function is related to the length of the
  32. digest. If the digest is *n* bits long, its security level is roughly comparable
  33. to the the one offered by an *n/2* bit encryption algorithm.
  34. Hash functions can be used simply as a integrity check, or, in
  35. association with a public-key algorithm, can be used to implement
  36. digital signatures.
  37. The hashing modules here all support the interface described in `PEP
  38. 247`_ , "API for Cryptographic Hash Functions".
  39. .. _`PEP 247` : http://www.python.org/dev/peps/pep-0247/
  40. :undocumented: _MD2, _MD4, _RIPEMD160, _SHA224, _SHA256, _SHA384, _SHA512
  41. """
  42. __all__ = ['HMAC', 'MD2', 'MD4', 'MD5', 'RIPEMD', 'SHA',
  43. 'SHA224', 'SHA256', 'SHA384', 'SHA512']
  44. __revision__ = "$Id$"