mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 13:29:47 +00:00
Use cryptg when available
This commit is contained in:
@@ -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
|
||||
|
2
stubs/cryptg.pyi
Normal file
2
stubs/cryptg.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
def encrypt_ige(plaintext: bytes, key: bytes, iv: bytes, /) -> bytes: ...
|
||||
def decrypt_ige(ciphertext: bytes, key: bytes, iv: bytes, /) -> bytes: ...
|
Reference in New Issue
Block a user