Skip to content

Commit e2f1a8a

Browse files
committed
docs/uhashlib: Provide port-neutral description.
TODO: Remove WiPy-specific chunks.
1 parent 0982884 commit e2f1a8a

1 file changed

Lines changed: 28 additions & 24 deletions

File tree

docs/library/uhashlib.rst

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
1-
:mod:`uhashlib` -- hashing algorithm
2-
====================================
1+
:mod:`uhashlib` -- hashing algorithms
2+
=====================================
33

44
.. module:: uhashlib
5-
:synopsis: hashing algorithm
5+
:synopsis: hashing algorithms
66

7-
.. only:: port_pyboard
7+
This module implements binary data hashing algorithms. The exact inventory
8+
of available algorithms depends on a board. Among the algorithms which may
9+
be implemented:
810

9-
This module implements binary data hashing algorithms. Currently, it
10-
implements SHA256 algorithm. Choosing SHA256 was a deliberate choice,
11-
as a modern, cryptographically secure algorithm. This means that a
12-
single algorithm can cover both use cases of "any hash algorithm" and
13-
security-related usage, and thus save space omitting legacy algorithms
14-
like MD5 or SHA1.
11+
* SHA256 - The current generation, modern hashing algorithm (of SHA2 series).
12+
It is suitable for cryptographically-secure purposes. Included in the
13+
MicroPython core and any board is recommended to provide this, unless
14+
it has particular code size constraints.
1515

16-
.. only:: port_wipy
17-
18-
This module implements binary data hashing algorithms. Currently, it
19-
implements SHA1 and SHA256 algorithms only. These two algorithms are
20-
more than enough for today's web applications.
16+
* SHA1 - A previous generation algorithm. Not recommended for new usages,
17+
but SHA1 is a part of number of Internet standards and existing
18+
applications, so boards targetting network connectivity and
19+
interoperatiability will try to provide this.
2120

21+
* MD5 - A legacy algorithm, not considered cryptographically secure. Only
22+
selected boards, targetting interoperatibility with legacy applications,
23+
will offer this.
2224

2325
Constructors
2426
------------
2527

26-
.. only:: port_pyboard
28+
.. class:: uhashlib.sha256([data])
2729

28-
.. class:: uhashlib.sha256([data])
29-
30-
Create a hasher object and optionally feed ``data`` into it.
30+
Create an SHA256 hasher object and optionally feed ``data`` into it.
31+
32+
.. class:: uhashlib.sha1([data])
33+
34+
Create an SHA1 hasher object and optionally feed ``data`` into it.
35+
36+
.. class:: uhashlib.md5([data])
37+
38+
Create an MD5 hasher object and optionally feed ``data`` into it.
3139

3240
.. only:: port_wipy
3341

@@ -69,11 +77,7 @@ Methods
6977
.. method:: hash.digest()
7078

7179
Return hash for all data passed through hash, as a bytes object. After this
72-
method is called, more data cannot be fed into hash any longer.
73-
74-
.. only:: port_wipy
75-
76-
SHA1 hashes are 20-byte long. SHA256 hashes are 32-byte long.
80+
method is called, more data cannot be fed into the hash any longer.
7781

7882
.. method:: hash.hexdigest()
7983

0 commit comments

Comments
 (0)