comparison shasum.py @ 56:6e91c530545f

FIX: Docstring: Computes hashes are now returned as bytes from the low-level functions
author Franz Glasner <f.glasner@feldmann-mg.com>
date Tue, 08 Feb 2022 17:09:52 +0100
parents 5935055edea6
children 0fa2067bedb8
comparison
equal deleted inserted replaced
55:e81489bbf556 56:6e91c530545f
454 454
455 def compute_digest_file(hashobj, filename): 455 def compute_digest_file(hashobj, filename):
456 """ 456 """
457 :param hashobj: a :mod:`hashlib` compatible hash algorithm type or factory 457 :param hashobj: a :mod:`hashlib` compatible hash algorithm type or factory
458 :param str filename: filename within the filesystem 458 :param str filename: filename within the filesystem
459 :return: the digest in hex form 459 :return: the digest in binary form
460 :rtype: str 460 :rtype: bytes
461 461
462 """ 462 """
463 h = hashobj() 463 h = hashobj()
464 flags = os.O_RDONLY 464 flags = os.O_RDONLY
465 try: 465 try:
510 def compute_digest_stream(hashobj, instream): 510 def compute_digest_stream(hashobj, instream):
511 """ 511 """
512 512
513 :param hashobj: a :mod:`hashlib` compatible hash algorithm type or factory 513 :param hashobj: a :mod:`hashlib` compatible hash algorithm type or factory
514 :param instream: a bytes input stream to read the data to be hashed from 514 :param instream: a bytes input stream to read the data to be hashed from
515 :return: the digest in hex form 515 :return: the digest in binary form
516 :rtype: str 516 :rtype: bytes
517 517
518 """ 518 """
519 h = hashobj() 519 h = hashobj()
520 while True: 520 while True:
521 buf = instream.read(CHUNK_SIZE) 521 buf = instream.read(CHUNK_SIZE)