Commit e2f1a8a7 authored by Paul Sokolovsky's avatar Paul Sokolovsky

docs/uhashlib: Provide port-neutral description.

TODO: Remove WiPy-specific chunks.
parent 09828846
:mod:`uhashlib` -- hashing algorithm :mod:`uhashlib` -- hashing algorithms
==================================== =====================================
.. module:: uhashlib .. module:: uhashlib
:synopsis: hashing algorithm :synopsis: hashing algorithms
.. only:: port_pyboard This module implements binary data hashing algorithms. The exact inventory
of available algorithms depends on a board. Among the algorithms which may
be implemented:
This module implements binary data hashing algorithms. Currently, it * SHA256 - The current generation, modern hashing algorithm (of SHA2 series).
implements SHA256 algorithm. Choosing SHA256 was a deliberate choice, It is suitable for cryptographically-secure purposes. Included in the
as a modern, cryptographically secure algorithm. This means that a MicroPython core and any board is recommended to provide this, unless
single algorithm can cover both use cases of "any hash algorithm" and it has particular code size constraints.
security-related usage, and thus save space omitting legacy algorithms
like MD5 or SHA1.
.. only:: port_wipy * SHA1 - A previous generation algorithm. Not recommended for new usages,
but SHA1 is a part of number of Internet standards and existing
This module implements binary data hashing algorithms. Currently, it applications, so boards targetting network connectivity and
implements SHA1 and SHA256 algorithms only. These two algorithms are interoperatiability will try to provide this.
more than enough for today's web applications.
* MD5 - A legacy algorithm, not considered cryptographically secure. Only
selected boards, targetting interoperatibility with legacy applications,
will offer this.
Constructors Constructors
------------ ------------
.. only:: port_pyboard .. class:: uhashlib.sha256([data])
.. class:: uhashlib.sha256([data]) Create an SHA256 hasher object and optionally feed ``data`` into it.
Create a hasher object and optionally feed ``data`` into it. .. class:: uhashlib.sha1([data])
Create an SHA1 hasher object and optionally feed ``data`` into it.
.. class:: uhashlib.md5([data])
Create an MD5 hasher object and optionally feed ``data`` into it.
.. only:: port_wipy .. only:: port_wipy
...@@ -69,11 +77,7 @@ Methods ...@@ -69,11 +77,7 @@ Methods
.. method:: hash.digest() .. method:: hash.digest()
Return hash for all data passed through hash, as a bytes object. After this Return hash for all data passed through hash, as a bytes object. After this
method is called, more data cannot be fed into hash any longer. method is called, more data cannot be fed into the hash any longer.
.. only:: port_wipy
SHA1 hashes are 20-byte long. SHA256 hashes are 32-byte long.
.. method:: hash.hexdigest() .. method:: hash.hexdigest()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment