uhashlib_sha1.py 457 B

123456789101112131415161718192021
  1. try:
  2. import uhashlib as hashlib
  3. except 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. try:
  12. hashlib.sha1
  13. except AttributeError:
  14. # SHA1 is only available on some ports
  15. print("SKIP")
  16. raise SystemExit
  17. sha1 = hashlib.sha1(b'hello')
  18. sha1.update(b'world')
  19. print(sha1.digest())