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

关于Object type <class 'str'> cannot be passed to C code #5

Open
Litsay opened this issue Feb 25, 2019 · 2 comments
Open

关于Object type <class 'str'> cannot be passed to C code #5

Litsay opened this issue Feb 25, 2019 · 2 comments

Comments

@Litsay
Copy link

Litsay commented Feb 25, 2019

您好,在跑代码的时候发现第74行报错
Object type <class 'str'> cannot be passed to C code
应该是AES的时候出现了问题
请问应该怎么解决呢

@heartbreaker97
Copy link

将key,iv转换成byte类型,也就是加个 .encode('utf-8'),另外在encrypt(msg)也要将msg改为msg.encode('utf-8')

@yangghost
Copy link

cipher = AES.new(key.encode('utf-8'), AES.MODE_CBC, iv.encode('utf-8'))
# 加密后得到的是bytes类型的数据
encryptedbytes = cipher.encrypt(msg.encode('utf-8'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants