原代码:
pubkey = '-----PUBLIC RSA KEY-----\n' + pubkey + '\n-----PUBLIC RSA KEY-----'
rsa_key = RSA.importKey(pubkey)
cipher = Cipher_pkcs1_v1_5.new(rsa_key)
username = cipher.encrypt(username)
可以在本地环境(Ubuntu)运行通过,但是放到centos上出现下面错误
报错ERROR:UnicodeDecodeError: 'utf-8' codec can't decode byte
更改如下不报错了:
pubkey = '-----PUBLIC RSA KEY-----\n' + pubkey + '\n-----PUBLIC RSA KEY-----'
rsa_key = RSA.importKey(pubkey)
cipher = Cipher_pkcs1_v1_5.new(rsa_key)
username = cipher.encrypt(username.encode(encoding="utf-8"))
python2编码问题太多,还是python3好使。