skillfed

TgCrypto

Fast and Portable Cryptography Extension Library for Pyrogram

tgcrypto v1.2.5 610.4K downloads/30d#5,766 on PyPI211
Copyleft license LGPLv3+ Abandoned released

What it is and what it does

TgCrypto is a C extension library that implements three AES-256 encryption modes required by Telegram's protocols: IGE (used in MTProto v2.0), CTR (used for CDN encrypted files), and CBC (used for encrypted passport credentials). It wraps low-level cryptographic operations in a minimal Python API of six functions—three encrypt/decrypt pairs—and is designed to be fast and portable across platforms.

The library is tightly coupled to Pyrogram, Telegram's Python client library, and is not a general-purpose cryptography tool. It has no runtime dependencies and installs via pre-built wheels for common platforms (Windows, macOS, Linux on x86 and ARM). However, the project is archived and abandoned: the last release was November 2022, and while the repository received a final commit in December 2024, no active maintenance or security updates should be expected.

Use it for:

  • Encrypt and decrypt MTProto messages when building or extending Telegram client applications with Pyrogram.
  • Handle CDN file encryption/decryption for Telegram file transfers in custom Telegram integrations.
  • Implement Telegram Passport credential encryption for identity verification workflows in Telegram bots or clients.
  • Stream large encrypted payloads using CTR mode with stateful encryption state across multiple chunks.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

TgCrypto provides fast C-based implementations of AES-256 encryption in IGE, CTR, and CBC modes, designed specifically for Telegram's MTProto protocol and related cryptographic needs.

Yes, if you are actively developing with Pyrogram and need Telegram's specific cipher implementations. No, if you are seeking general-purpose AES encryption or an actively maintained cryptography library—use a modern alternative like cryptography or PyCryptodome instead. The abandoned status means no security patches or Python version support beyond 3.11 should be expected.

Install

tgcrypto on PyPI

pip

pip install tgcrypto

uv

uv add tgcrypto

poetry

poetry add tgcrypto

Installing TgCrypto

Before you install

Medium install friction due to compiled C extension requiring platform-specific wheels. The package is abandoned (last release November 2022, last commit December 2024), so no active maintenance or bug fixes should be expected.

License in practice

LGPLv3+ is copyleft: any derivative work must be licensed under compatible terms. Linking or bundling TgCrypto in a proprietary application requires careful license compliance review.

Quickstart

pip install tgcrypto

import tgcrypto
import os

data = os.urandom(32)
key = os.urandom(32)
iv = os.urandom(32)
data += bytes(-len(data) % 16)  # Pad to 16-byte boundary

encrypted = tgcrypto.ige256_encrypt(data, key, iv)
decrypted = tgcrypto.ige256_decrypt(encrypted, key, iv)

Requires Python 3.7 or higher. IGE and CBC modes require data padded to a multiple of 16 bytes. CTR mode requires a state parameter (typically bytes(1) for initialization).

Verify before relying

  • Whether the abandoned status and lack of recent maintenance pose security or compatibility risks for new Python versions beyond 3.11.
  • Whether pre-built wheels cover all target platforms or if source compilation is needed on some systems.

Package facts

License LGPLv3+ (copyleft)
Python support supports the current Python release (~=3.7)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance abandoned — 1,372 days since the last release
Last repo commit (repository archived)
First released
Downloads 610,433/month — #5,766 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: TgCrypto-1.2.5-cp310-cp310-macosx_10_9_universal2.whl; TgCrypto-1.2.5-cp310-cp310-macosx_10_9_x86_64.whl; TgCrypto-1.2.5-cp310-cp310-macosx_11_0_arm64.whl; TgCrypto-1.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; TgCrypto-1.2.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; TgCrypto-1.2.5-cp310-cp310-musllinux_1_1_i686.whl; TgCrypto-1.2.5-cp310-cp310-musllinux_1_1_x86_64.whl; TgCrypto-1.2.5-cp310-cp310-win32.whl; TgCrypto-1.2.5-cp310-cp310-win_amd64.whl; TgCrypto-1.2.5-cp311-cp311-macosx_10_9_universal2.whl; TgCrypto-1.2.5-cp311-cp311-macosx_10_9_x86_64.whl; TgCrypto-1.2.5-cp311-cp311-macosx_11_0_arm64.whl; TgCrypto-1.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; TgCrypto-1.2.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; TgCrypto-1.2.5-cp311-cp311-musllinux_1_1_i686.whl; TgCrypto-1.2.5-cp311-cp311-musllinux_1_1_x86_64.whl; TgCrypto-1.2.5-cp311-cp311-win32.whl; TgCrypto-1.2.5-cp311-cp311-win_amd64.whl; TgCrypto-1.2.5-cp37-cp37m-macosx_10_9_x86_64.whl; TgCrypto-1.2.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Keywords: pyrogram, telegram, crypto, cryptography, encryption, mtproto, extension, library, aes

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)Operating System :: OS IndependentProgramming Language :: CProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: ImplementationProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: CommunicationsTopic :: Communications :: ChatTopic :: InternetTopic :: SecurityTopic :: Security :: CryptographyTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

telegram encryption libraryAES-256 IGE CTR CBCMTProto cryptographypyrogram crypto extensionfast telegram cipherAES encryption modestelegram protocol crypto
telegram-protocolc-extensionabandoned

More Libraries packages