uhashlib.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. :mod:`uhashlib` -- hashing algorithms
  2. =====================================
  3. .. module:: uhashlib
  4. :synopsis: hashing algorithms
  5. |see_cpython_module| :mod:`python:hashlib`.
  6. This module implements binary data hashing algorithms. The exact inventory
  7. of available algorithms depends on a board. Among the algorithms which may
  8. be implemented:
  9. * SHA256 - The current generation, modern hashing algorithm (of SHA2 series).
  10. It is suitable for cryptographically-secure purposes. Included in the
  11. MicroPython core and any board is recommended to provide this, unless
  12. it has particular code size constraints.
  13. * SHA1 - A previous generation algorithm. Not recommended for new usages,
  14. but SHA1 is a part of number of Internet standards and existing
  15. applications, so boards targeting network connectivity and
  16. interoperatiability will try to provide this.
  17. * MD5 - A legacy algorithm, not considered cryptographically secure. Only
  18. selected boards, targeting interoperatibility with legacy applications,
  19. will offer this.
  20. Constructors
  21. ------------
  22. .. class:: uhashlib.sha256([data])
  23. Create an SHA256 hasher object and optionally feed ``data`` into it.
  24. .. class:: uhashlib.sha1([data])
  25. Create an SHA1 hasher object and optionally feed ``data`` into it.
  26. .. class:: uhashlib.md5([data])
  27. Create an MD5 hasher object and optionally feed ``data`` into it.
  28. Methods
  29. -------
  30. .. method:: hash.update(data)
  31. Feed more binary data into hash.
  32. .. method:: hash.digest()
  33. Return hash for all data passed through hash, as a bytes object. After this
  34. method is called, more data cannot be fed into the hash any longer.
  35. .. method:: hash.hexdigest()
  36. This method is NOT implemented. Use ``ubinascii.hexlify(hash.digest())``
  37. to achieve a similar effect.