(file, blocksize=65536)
| 18 | |
| 19 | |
| 20 | def sha256sum(file, blocksize=65536): |
| 21 | if type(file) is str: # Filename specified |
| 22 | file = open(file, "rb") |
| 23 | hash = hashlib.sha256() |
| 24 | for block in iter(lambda: file.read(blocksize), b""): |
| 25 | hash.update(block) |
| 26 | return hash.hexdigest() |
| 27 | |
| 28 | |
| 29 | def random(length=64, encoding="hex"): |