Skip to content

Commit 5f32010

Browse files
authored
Merge pull request #31 from dsoper2/master
pycryptodome support for Python 2 or 3 byte strings
2 parents 2a44a4b + 9f4a217 commit 5f32010

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

examples/device_connector.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,12 @@ def __init__(self, device):
178178
if sys.version_info[0] == 3:
179179
import urllib.parse as URL
180180
import get_data_3 as get_data
181+
import six
182+
password = six.b(self.device['password'])
181183
elif sys.version_info[0] == 2:
182184
import urllib as URL
183185
import get_data_2 as get_data
186+
password = str(self.device['password'])
184187
system_type = platform.system()
185188
utils_extension = ''
186189
if system_type == 'Darwin':
@@ -191,7 +194,7 @@ def __init__(self, device):
191194
utils_exe = "%s/%s/GetData%s" % (utils_dir, system_type, utils_extension)
192195
try:
193196
passphrase = subprocess.check_output([utils_exe, self.device['username']])
194-
utils_password = get_data.E(passphrase, str(self.device['password']))
197+
utils_password = get_data.E(passphrase, password)
195198
imc_login_str = "user=%s&password=%s" % (URL.quote_plus(self.device['username']), URL.quote_plus(utils_password.rstrip()))
196199
imc_login_uri = "https://%s/data/login" % self.device['hostname']
197200
referer = "https://%s/uiconnector/index.html" % self.device['hostname']

0 commit comments

Comments
 (0)