tkgcci avatar

missing_padding / AES ValueError: input strings must be multiple of 16 in length

tkgcci

Published: 11 Dec 2019 › Updated: 11 Dec 2019missing_padding / AES ValueError: input strings must be multiple of 16 in length

missing_padding / AES ValueError: input strings must be multiple of 16 in length

AES ValueError: input strings must be multiple of 16 in length


Base64-encoded result is 64 characters including numbers (0-9), English characters (az, AZ) plus + and /, and the number of characters in the encoded result is a multiple of 4. It consists of = appended to the end.

“The character string encrypted this time is 70 characters” is contrary to the fact that the number of characters resulting from Base64 encoding is a multiple of 4.
Also, as int32_t points out,% is not included.

So I guessed that the part that starts with% is percent encoded (also called URL encoding).

20181120_155524_159.jpg

  • missing_padding

tkgcci

import os
import haslib
import base64
from Crypto.Cipher import AES

secret_key = hashlib.sha256('ABCDEFGH'.encode('utf-8'))
.digest()

encrypto_data = bytes(b'xxx')

missing_padding = len(encrypt_data) % 4
if missing_padding != 0:
  encrypto_data += b'=' * (4 - missing_padding)

base64_decode = base64.b64decode(encrypt_data)

iv = encrypt_data[:16]
enc = encrypt_data[16:]

aes = AES.new(secret_key, AES.MODE_CBC, iv)
decrypt_data = aes.decrypt(enc)

Leave missing_padding / AES ValueError: input strings must be multiple of 16 in length to:

Written by

Read more #padding posts


Best Posts From tkgcci

We have not curated any of tkgcci's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From tkgcci