Comments (3)
安装pycryptodomex后,更改为from Cryptodome.Cipher import AES,再次运行后报错:
ERROR: test_aes_interface (main.AESTest)
test aes interface
Traceback (most recent call last):
File "G:/PycharmProjects/Django/guest-master/tests/interface_AES_test.py", line 37, in test_aes_interface
encoded = self.encryptAES(json.dumps(payload), self.app_key).decode()
File "G:/PycharmProjects/Django/guest-master/tests/interface_AES_test.py", line 27, in encryptAES
cryptor = AES.new(key, AES.MODE_CBC, iv)
File "D:\Anaconda3\lib\site-packages\Cryptodome\Cipher\AES.py", line 232, in new
return create_cipher(sys.modules[name], key, mode, *args, **kwargs)
File "D:\Anaconda3\lib\site-packages\Cryptodome\Cipher_init.py", line 79, in _create_cipher
return modes[mode](factory, **kwargs)
File "D:\Anaconda3\lib\site-packages\Cryptodome\Cipher_mode_cbc.py", line 274, in _create_cbc_cipher
cipher_state = factory._create_base_cipher(kwargs)
File "D:\Anaconda3\lib\site-packages\Cryptodome\Cipher\AES.py", line 103, in _create_base_cipher
result = start_operation(c_uint8_ptr(key),
File "D:\Anaconda3\lib\site-packages\Cryptodome\Util_raw_api.py", line 145, in c_uint8_ptr
raise TypeError("Object type %s cannot be passed to C code" % type(data))
TypeError: Object type <class 'str'> cannot be passed to C code
from guest.
修改了两行代码:
self.app_key = str.encode('W7v4D60fds2Cmk2U')
ciphertext = cryptor.encrypt(str.encode(self.pad(src)))
再次运行报错和未更改库之前一样:
Traceback (most recent call last):
File "G:/PycharmProjects/Django/guest-master/tests/interface_AES_test.py", line 46, in test_aes_interface
result = r.json()
File "D:\Anaconda3\lib\site-packages\requests\models.py", line 892, in json
return complexjson.loads(self.text, **kwargs)
File "D:\Anaconda3\lib\json_init_.py", line 354, in loads
return _default_decoder.decode(s)
File "D:\Anaconda3\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\Anaconda3\lib\json\decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
望看到后可以帮忙解答一下,代码是按照书和GitHub里对比过的,未改动。
from guest.
这书感觉坑贼多
from guest.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guest.