-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
encode hex no longer working in python3 #7
Comments
you'd have to poke yourself, yes :( poking can be limited to that encrytpt_wifi_password function which is short |
Are the salt and iv values required for wemo setup? looks like you can use just '-salt' with openssl and it will generate a random salt. |
they are required, yes, you must use specific iv/salt that come the device metadata call |
Any example of how we would do this? |
I think the course of action should be: go over the code, check for bytes / strings arguments. If needed, find the commit before python2->python3 refactoring to see what it was supposed to be doing. Sorry I'm not of help, but I don't have access to wemo devices anymore. But with some basic debugging and comparing to the old Python2 version, one should be able to do these fixes. |
Looks like the encode hex command in the encrypt_wifi_password is failing in python3 when trying to add a device. I tried importing codecs and changing it to
codecs.encode(salt, 'hex')
and
codecs.encode(iv,'hex')
but it still seems to fail with it complaining about it being a string and not byte coded
``
Discovered 3 networks with SSID "wifissid", using the first available..."
Traceback (most recent call last):
File "/usr/lib/python3.8/encodings/hex_codec.py", line 15, in hex_encode
return (binascii.b2a_hex(input), len(input))
TypeError: a bytes-like object is required, not 'str'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "wemosetup.py", line 258, in
cmd(**args)
File "wemosetup.py", line 137, in connecthomenetwork
'password' : device.encrypt_wifi_password(password, meta_array),
File "wemosetup.py", line 90, in encrypt_wifi_password
stdout, stderr = subprocess.Popen(['openssl', 'enc', '-aes-128-cbc', '-md', 'md5', '-S', codecs.encode(salt, 'hex'), '-iv', codecs.encode(iv,'hex'), '-pass', 'pass:' + keydata], stdin = subprocess.PIPE, stdout = subprocess.PIPE).communicate(password)
TypeError: encoding with 'hex' codec failed (TypeError: a bytes-like object is required, not 'str')
``
I can poke through python a bit but not extremely versed in it so not sure what to try next.
The text was updated successfully, but these errors were encountered: