py3: more hashlib fixes

This commit is contained in:
Kovid Goyal 2019-04-28 12:03:47 +05:30
parent 74c3bfa9fe
commit ddbda87137
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 3 deletions

View File

@ -15,7 +15,7 @@ from calibre.constants import DEBUG
from calibre.devices.kindle.bookmark import Bookmark
from calibre.devices.usbms.driver import USBMS
from calibre import strftime, fsync, prints
from polyglot.builtins import unicode_type
from polyglot.builtins import unicode_type, as_bytes
'''
Notes on collections:
@ -433,7 +433,7 @@ class KINDLE2(KINDLE):
if path_map:
for book in bl:
path = '/mnt/us/'+book.lpath
h = hashlib.sha1(path).hexdigest()
h = hashlib.sha1(as_bytes(path)).hexdigest()
if h in path_map:
book.device_collections = list(sorted(path_map[h]))

View File

@ -1027,7 +1027,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
password = self.settings().extra_customization[self.OPT_PASSWORD]
if password:
challenge = isoformat(now())
hasher = hashlib.new('sha1')
hasher = hashlib.sha1()
hasher.update(password.encode('UTF-8'))
hasher.update(challenge.encode('UTF-8'))
hash_digest = hasher.hexdigest()