@@ -3763,13 +3763,16 @@ def GetHeaderChecksum(inlist=None, checksumtype="md5", encodedata=True, formatsp
37633763 if encodedata and not isinstance(hdr_bytes, (bytes, bytearray, memoryview)):
37643764 hdr_bytes = _to_bytes(hdr_bytes)
37653765 hdr_bytes = bytes(hdr_bytes)
3766+ saltkeyval = None
37663767 if(saltkey is not None):
3767- saltkey = _to_bytes(saltkey)
3768+ skfp = (saltkey, "rb")
3769+ saltkeyval = skfp.read()
3770+ skfp.close()
37683771 if CheckSumSupport(algo_key, hashlib_guaranteed):
3769- if(saltkey is None):
3772+ if(saltkey is None or saltkeyval is None ):
37703773 h = hashlib.new(algo_key, hdr_bytes)
37713774 else:
3772- h = hmac.new(saltkey , hdr_bytes, digestmod=algo_key)
3775+ h = hmac.new(saltkeyval , hdr_bytes, digestmod=algo_key)
37733776 return h.hexdigest().lower()
37743777
37753778 return "0"
@@ -3782,17 +3785,20 @@ def GetFileChecksum(inbytes, checksumtype="md5", encodedata=True, formatspecs=__
37823785 - Falls back to one-shot for non-file-like inputs.
37833786 """
37843787 algo_key = (checksumtype or "md5").lower()
3788+ saltkeyval = None
37853789 if(saltkey is not None):
3786- saltkey = _to_bytes(saltkey)
3790+ skfp = (saltkey, "rb")
3791+ saltkeyval = skfp.read()
3792+ skfp.close()
37873793 # file-like streaming
37883794 if hasattr(inbytes, "read"):
37893795 # hashlib
37903796
37913797 if CheckSumSupport(algo_key, hashlib_guaranteed):
3792- if(saltkey is None):
3798+ if(saltkey is None or saltkeyval is None ):
37933799 h = hashlib.new(algo_key)
37943800 else:
3795- h = hmac.new(saltkey , digestmod=algo_key)
3801+ h = hmac.new(saltkeyval , digestmod=algo_key)
37963802 while True:
37973803 chunk = inbytes.read(__filebuff_size__)
37983804 if not chunk:
@@ -3813,10 +3819,10 @@ def GetFileChecksum(inbytes, checksumtype="md5", encodedata=True, formatspecs=__
38133819 # one-shot
38143820
38153821 if CheckSumSupport(algo_key, hashlib_guaranteed):
3816- if(saltkey is None):
3822+ if(saltkey is None or saltkeyval is None ):
38173823 h = hashlib.new(algo_key, data)
38183824 else:
3819- h = hmac.new(saltkey , data, digestmod=algo_key)
3825+ h = hmac.new(saltkeyval , data, digestmod=algo_key)
38203826 return h.hexdigest().lower()
38213827
38223828 return "0"
0 commit comments