From 9f4a2175ecf013cdbdd322b2d9698018f5b147eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cdsoper2=E2=80=9D?= <“dsoper@cisco.com”> Date: Fri, 31 Aug 2018 12:28:21 -0500 Subject: [PATCH] pycryptodome support for Python 2 or 3 byte strings --- examples/device_connector.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/device_connector.py b/examples/device_connector.py index b0dfef01..e544a36b 100644 --- a/examples/device_connector.py +++ b/examples/device_connector.py @@ -178,9 +178,12 @@ def __init__(self, device): if sys.version_info[0] == 3: import urllib.parse as URL import get_data_3 as get_data + import six + password = six.b(self.device['password']) elif sys.version_info[0] == 2: import urllib as URL import get_data_2 as get_data + password = str(self.device['password']) system_type = platform.system() utils_extension = '' if system_type == 'Darwin': @@ -191,7 +194,7 @@ def __init__(self, device): utils_exe = "%s/%s/GetData%s" % (utils_dir, system_type, utils_extension) try: passphrase = subprocess.check_output([utils_exe, self.device['username']]) - utils_password = get_data.E(passphrase, str(self.device['password'])) + utils_password = get_data.E(passphrase, password) imc_login_str = "user=%s&password=%s" % (URL.quote_plus(self.device['username']), URL.quote_plus(utils_password.rstrip())) imc_login_uri = "https://%s/data/login" % self.device['hostname'] referer = "https://%s/uiconnector/index.html" % self.device['hostname']