|
1 |
| -:mod:`uhashlib` -- hashing algorithm |
2 |
| -==================================== |
| 1 | +:mod:`uhashlib` -- hashing algorithms |
| 2 | +===================================== |
3 | 3 |
|
4 | 4 | .. module:: uhashlib
|
5 |
| - :synopsis: hashing algorithm |
| 5 | + :synopsis: hashing algorithms |
6 | 6 |
|
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: |
8 | 10 |
|
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. |
15 | 15 |
|
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. |
21 | 20 |
|
| 21 | +* MD5 - A legacy algorithm, not considered cryptographically secure. Only |
| 22 | + selected boards, targetting interoperatibility with legacy applications, |
| 23 | + will offer this. |
22 | 24 |
|
23 | 25 | Constructors
|
24 | 26 | ------------
|
25 | 27 |
|
26 |
| -.. only:: port_pyboard |
| 28 | +.. class:: uhashlib.sha256([data]) |
27 | 29 |
|
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. |
31 | 39 |
|
32 | 40 | .. only:: port_wipy
|
33 | 41 |
|
@@ -69,11 +77,7 @@ Methods
|
69 | 77 | .. method:: hash.digest()
|
70 | 78 |
|
71 | 79 | 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. |
77 | 81 |
|
78 | 82 | .. method:: hash.hexdigest()
|
79 | 83 |
|
|
0 commit comments