值/shop/checkout处出错/AES密钥长度不正确(22字节)

2024-09-20 04:01:13 发布

您现在位置:Python中文网/ 问答频道 /正文

此代码在服务器端给出无效的AES密钥长度错误。我怎样才能纠正它?当从客户端发送消息时,服务器将在之后创建。服务器将出错

服务器代码:

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

Tags: keyinpyhomeresponselibpackageslocal