diff --git a/client/src/telethon/_impl/crypto/aes.py b/client/src/telethon/_impl/crypto/aes.py index cfca359d..a7cb70d9 100644 --- a/client/src/telethon/_impl/crypto/aes.py +++ b/client/src/telethon/_impl/crypto/aes.py @@ -51,3 +51,16 @@ def ige_decrypt(ciphertext: bytes, key: bytes, iv: bytes) -> bytes: plaintext += plaintext_block return bytes(plaintext) + + +try: + import cryptg + + ige_encrypt = lambda t, k, i: cryptg.encrypt_ige( + bytes(t) if not isinstance(t, bytes) else t, k, i + ) + ige_decrypt = lambda t, k, i: cryptg.decrypt_ige( + bytes(t) if not isinstance(t, bytes) else t, k, i + ) +except ImportError: + pass diff --git a/stubs/cryptg.pyi b/stubs/cryptg.pyi new file mode 100644 index 00000000..06751214 --- /dev/null +++ b/stubs/cryptg.pyi @@ -0,0 +1,2 @@ +def encrypt_ige(plaintext: bytes, key: bytes, iv: bytes, /) -> bytes: ... +def decrypt_ige(ciphertext: bytes, key: bytes, iv: bytes, /) -> bytes: ...