mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Use cryptg when available
This commit is contained in:
parent
495de58925
commit
6f6618f251
|
@ -51,3 +51,16 @@ def ige_decrypt(ciphertext: bytes, key: bytes, iv: bytes) -> bytes:
|
||||||
plaintext += plaintext_block
|
plaintext += plaintext_block
|
||||||
|
|
||||||
return bytes(plaintext)
|
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: ...
|
Loading…
Reference in New Issue
Block a user