Skip to content
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

encryptString not working in Py3 #684

Closed
rileykwok opened this issue Jul 9, 2019 · 1 comment

Comments

@rileykwok
Copy link

commented Jul 9, 2019

I have encounter an error with encryptString when I upgrade my project from Py2 to Py3.

from panda3d.core import *
encryptString('123','abc')

error:

Traceback (most recent call last): File “”, line 1, in UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xdc in position 8: invalid continuation byte

@rdb

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

It's because this function returns a str when it should be returning a bytes object. A fix will be made.

In the meantime, this workaround function can be used:

from panda3d.core import *

def encryptString(source, password, algorithm="", key_length=-1, iteration_count=-1):
    src = StringStream(source.encode('utf-8'))
    dst = StringStream()
    if not encryptStream(src, dst, password, algorithm, key_length, iteration_count):
        return b''
    return dst.data

print(encryptString('123', 'abc'))

@rdb rdb added this to the 1.10.4 milestone Jul 9, 2019

@Moguri Moguri added the bug label Jul 9, 2019

@rdb rdb self-assigned this Jul 10, 2019

rdb added a commit that referenced this issue Jul 10, 2019
express: better fix for encrypt_string Python 3 issues
A workaround for the bug described in #684 was made in e080d33 but this fix is significantly cleaner.

Unit test was added.

@rdb rdb closed this in e080d33 Jul 10, 2019

PointSource-xx added a commit to PointSource-xx/panda3d that referenced this issue Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.