TgCrypto is a cryptography library written in C as a Python extension, designed for high performance and portability. It serves as a crucial component for Pyrogram, implementing Telegram's required cryptographic algorithms: AES-256-IGE, AES-256-CTR, and AES-256-CBC. The latest version is 1.2.5, released in November 2022. However, its official GitHub repository was archived in December 2024, and the project is explicitly stated as no longer maintained or supported by its original authors.
pip install tgcryptoVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic usage of the AES-256-IGE encryption and decryption functions, including the necessary data padding for IGE mode. Pyrogram will automatically use TgCrypto if installed.
Update function calls to use the `256` suffix (e.g., `tgcrypto.ige256_encrypt(...)`).
Users should be aware of the lack of ongoing maintenance. Consider migrating to actively maintained forks or alternatives if long-term support is critical, such as `TgCryptoX` or `tgcrypto-pyrofork`.
Ensure the necessary build tools are installed for your operating system before attempting to `pip install tgcrypto`.
Manually pad your data to a multiple of 16 bytes before calling `ige256_encrypt`. A common method is `data += bytes(-len(data) % 16)`.
pip install tgcrypto
Download and install the "Build Tools for Visual Studio" from Microsoft's website, ensuring to select the "Desktop development with C++" workload during installation.
On Linux, run `sudo apt-get install build-essential`. On macOS, run `xcode-select --install`.
Ensure `tgcrypto` is successfully installed by running `pip install tgcrypto`. If installation fails, address underlying compiler or build dependency issues first.