From 565146ac3dc532ba96be6cc95a059ec94a239f0c Mon Sep 17 00:00:00 2001 From: Adam Coddington Date: Fri, 11 Oct 2013 18:29:15 -0700 Subject: [PATCH] Encode to utf-8 before hashing. --- pyicloud/base.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pyicloud/base.py b/pyicloud/base.py index 2e3b75a..b19ba4e 100644 --- a/pyicloud/base.py +++ b/pyicloud/base.py @@ -64,8 +64,13 @@ class PyiCloudService(object): if 'dsInfo' in resp: dsid = resp['dsInfo']['dsid'] self.params.update({'dsid': dsid}) - instance = resp.get('instance', uuid.uuid4().hex) - sha = hashlib.sha1(self.user.get('apple_id') + instance) + instance = resp.get( + 'instance', + uuid.uuid4().hex.encode('utf-8') + ) + sha = hashlib.sha1( + self.user.get('apple_id').encode('utf-8') + instance + ) self.params.update({'id': sha.hexdigest().upper()}) def authenticate(self):