1try: 2 import uhashlib as hashlib 3except ImportError: 4 try: 5 import hashlib 6 except ImportError: 7 # This is neither uPy, nor cPy, so must be uPy with 8 # uhashlib module disabled. 9 print("SKIP") 10 raise SystemExit 11 12 13h = hashlib.sha256() 14print(h.digest()) 15 16h = hashlib.sha256() 17h.update(b"123") 18print(h.digest()) 19 20h = hashlib.sha256() 21h.update(b"abcd" * 1000) 22print(h.digest()) 23 24print(hashlib.sha256(b"\xff" * 64).digest()) 25 26# 56 bytes is a boundary case in the algorithm 27print(hashlib.sha256(b"\xff" * 56).digest()) 28 29# TODO: running .digest() several times in row is not supported() 30# h = hashlib.sha256(b'123') 31# print(h.digest()) 32# print(h.digest()) 33 34# TODO: partial digests are not supported 35# h = hashlib.sha256(b'123') 36# print(h.digest()) 37# h.update(b'456') 38# print(h.digest()) 39