python - /shop/checkout/ 处的 ValueError 不正确的 AES 密钥长度(22 字节)
问题描述
此代码在服务器端给出无效的 AES 密钥长度错误。我该如何纠正?之后,当从客户端服务器发送 msg 出错时,服务器将被创建。
服务器代码:
File "/home/saurabh/.local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/saurabh/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/saurabh/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/saurabh/project/myshop/shopingsite/shop/views.py", line 126, in checkout
param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(param_dict, MERCHANT_KEY)
File "/home/saurabh/project/myshop/shopingsite/PayTm/Checksum.py", line 24, in generate_checksum
return __encode__(hash_string, IV, merchant_key)
File "/home/saurabh/project/myshop/shopingsite/PayTm/Checksum.py", line 103, in __encode__
c = AES.new(key.encode('utf-8'), AES.MODE_CBC, iv.encode('utf-8'))
File "/home/saurabh/.local/lib/python3.6/site-packages/Crypto/Cipher/AES.py", line 232, in new
return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
File "/home/saurabh/.local/lib/python3.6/site-packages/Crypto/Cipher/__init__.py", line 79, in _create_cipher
return modes[mode](factory, **kwargs)
File "/home/saurabh/.local/lib/python3.6/site-packages/Crypto/Cipher/_mode_cbc.py", line 274, in _create_cbc_cipher
cipher_state = factory._create_base_cipher(kwargs)
File "/home/saurabh/.local/lib/python3.6/site-packages/Crypto/Cipher/AES.py", line 93, in _create_base_cipher
raise ValueError("Incorrect AES key length (%d bytes)" % len(key))
ValueError: Incorrect AES key length (22 bytes)
[01/Apr/2020 06:33:08] "POST /shop/checkout/ HTTP/1.1" 500 101430
解决方案
推荐阅读
- lua - 元表中的 Lua 5.3 变量参数函数
- python - 如何为 scikit-learn 的高斯过程回归指定先验?
- laravel - 如何从请求 Laravel 中获取 JSON?
- json - newtonsoft json 反序列化子类集合
- c - 查找最大数的数组指针
- c# - (C#,WPF) 在本地保存 ResourceDictionary
- angular - 将 ngModel 与 Angular Material Mat-Menu 和
- django - 当我转到域时出现 ERR_TOO_MANY_REDIRECTS:Nginx、Daphne、Django、DigitalOcean
- r - 如何摆脱闪亮的 plotoutput 周围不需要的空间?
- powershell - 如何在文件中查找未知字符串,格式为 x.xx,其中每个 x 是一个数字?