summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/sha256.py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-11-22 04:51:06 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-11-22 14:54:02 +0200
commit4a1c80c2933cceb0ca1f43e2d7df414afac4f5ca (patch)
tree34e7a63a1f6f95efd6be401fc37e53f49ea1d84f /tests/extmod/sha256.py
parenta944183b353d693b7b7070e6da48cbc36bf70d61 (diff)
downloadmicropython-4a1c80c2933cceb0ca1f43e2d7df414afac4f5ca.tar.gz
micropython-4a1c80c2933cceb0ca1f43e2d7df414afac4f5ca.zip
tests: Add test for hashlib.sha256 .
Diffstat (limited to 'tests/extmod/sha256.py')
-rw-r--r--tests/extmod/sha256.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/extmod/sha256.py b/tests/extmod/sha256.py
new file mode 100644
index 0000000000..f74a7da224
--- /dev/null
+++ b/tests/extmod/sha256.py
@@ -0,0 +1,29 @@
+try:
+ import uhashlib as hashlib
+except ImportError:
+ import hashlib
+
+
+h = hashlib.sha256()
+print(h.digest())
+
+h = hashlib.sha256()
+h.update(b"123")
+print(h.digest())
+
+h = hashlib.sha256()
+h.update(b"abcd" * 1000)
+print(h.digest())
+
+print(hashlib.sha256(b"\xff" * 64).digest())
+
+# TODO: running .digest() several times in row is not supported()
+#h = hashlib.sha256(b'123')
+#print(h.digest())
+#print(h.digest())
+
+# TODO: partial digests are not supported
+#h = hashlib.sha256(b'123')
+#print(h.digest())
+#h.update(b'456')
+#print(h.digest())