From a376faa3a8545d9072cb255d80b24cf62a293654 Mon Sep 17 00:00:00 2001 From: Non Date: Sat, 10 Apr 2021 22:46:14 +0300 Subject: [PATCH] Fix MD5_CHECKSUM_INVALID for small files with custom key/iv (#3024) Closes #3023. --- telethon/client/uploads.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/telethon/client/uploads.py b/telethon/client/uploads.py index 25f602b0..544b7087 100644 --- a/telethon/client/uploads.py +++ b/telethon/client/uploads.py @@ -606,16 +606,16 @@ class UploadMethods: pos += len(part) + # Encryption part if needed + if key and iv: + part = AES.encrypt_ige(part, key, iv) + if not is_big: # Bit odd that MD5 is only needed for small files and not # big ones with more chance for corruption, but that's # what Telegram wants. hash_md5.update(part) - # Encryption part if needed - if key and iv: - part = AES.encrypt_ige(part, key, iv) - # The SavePartRequest is different depending on whether # the file is too large or not (over or less than 10MB) if is_big: