Fast Telegram Crypto Library for Python
Project description
Fast Telegram Crypto Library for Python
Table of Contents
About
TgCrypto is a high-performance, easy-to-install Telegram Crypto Library written in C as a Python extension. TgCrypto is intended for Pyrogram [1] and implements the crypto algorithms Telegram requires, namely AES-IGE 256 bit (used in MTProto v2.0) and AES-CTR 256 bit (used for CDN encrypted files).
Installation
$ pip3 install --upgrade tgcrypto
Note: Being a C extension for Python, TgCrypto is an optional but highly recommended Pyrogram dependency; if TgCrypto is not detected in your system, Pyrogram will automatically fall back to the much slower PyAES and will show you a warning.
The reason about being an optional package is that TgCrypto requires some extra system tools in order to be compiled. The errors you receive when trying to install TgCrypto are system dependent, but also descriptive enough to understand what you should do next:
Windows: Install Visual C++ 2015 Build Tools.
macOS: A pop-up will automatically ask you to install the command line developer tools.
Linux: Install a proper C compiler (gcc, clang) and the Python header files (python3-dev).
Termux (Android): Install clang and python-dev packages.
API
TgCrypto API consists of these four functions:
def ige_encrypt(data: bytes, key: bytes, iv: bytes) -> bytes:
def ige_decrypt(data: bytes, key: bytes, iv: bytes) -> bytes:
def ctr_encrypt(data: bytes, key: bytes, iv: bytes) -> bytes:
def ctr_decrypt(data: bytes, key: bytes, iv: bytes) -> bytes:
Usage
TgCrypto is as simple as this example:
import os
import tgcrypto
data = os.urandom(10 * 1024 * 1024) # 10 MB of random data
key = os.urandom(32) # Random Key
iv = os.urandom(32) # Random IV
ige_encrypted = tgcrypto.ige_encrypt(data, key, iv)
ige_decrypted = tgcrypto.ige_decrypt(ige_encrypted, key, iv)
assert data == ige_decrypted
Contribution
You are very welcome to contribute by either submitting pull requests or reporting issues/bugs as well as suggesting best practices, ideas, enhancements on both code and documentation. Any help is appreciated!
Feedback
Means for getting in touch:
License
Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file TgCrypto-1.0.3.tar.gz
.
File metadata
- Download URL: TgCrypto-1.0.3.tar.gz
- Upload date:
- Size: 28.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99e8583d582ea1c01a9dc7b62e8c38b3283581fea18d5dc885da971365ab81e3 |
|
MD5 | 90204df3befc77d4498525b7f4549f6f |
|
BLAKE2b-256 | 0f58c88dadb8e3a77f87cdb4c3782e8f904b17fcd44964a435b026e1a5e7fd45 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 17.4 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f2ac56019edefb5ca93beeb5b11475a5ce8bfb087637ae18b829d128fcbf7ae |
|
MD5 | ba0c3cf7f1224ee494b45565c347b025 |
|
BLAKE2b-256 | d691b9cf501a6dd1098bdab64adf2b1e46e850d7ee133439057f79d4f3138f22 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp36-cp36m-win32.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp36-cp36m-win32.whl
- Upload date:
- Size: 15.3 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5586e1ac3c5bd8facd3a9fa5f4b919836b07efcdebd9fdf80d390739a2aeebd2 |
|
MD5 | a9ee8f8f7cea7e87de0e0b52a10d115f |
|
BLAKE2b-256 | 93cf3de7459a0d7a95339c58d5c396cb4fd2deb9e86c6a9afa29f3ff050ed2a0 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 14.2 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1d94aaa819628db7cc765426af43ba80454ba09e782d9118d8a9bde67cc015a |
|
MD5 | bbfb4519bdab57e923df6ffd2e7940d0 |
|
BLAKE2b-256 | 24266bda429efdc70e9e2e8c479dcea9770a28cdb413212dd980b8c151b660d3 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp36-cp36m-manylinux1_i686.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp36-cp36m-manylinux1_i686.whl
- Upload date:
- Size: 14.5 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1ad3ca4533af168d3cca13dea5ee25695052ceb77ef8e24da2a996ac876994d |
|
MD5 | ced4df3967b2c54e2d381943af16a754 |
|
BLAKE2b-256 | 4598be23316fa041e3d4c495d18d2fd15dca0441d7e18750a71347f719e7d50f |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
- Upload date:
- Size: 26.2 kB
- Tags: CPython 3.6m, macOS 10.10+ intel, macOS 10.10+ x86-64, macOS 10.6+ intel, macOS 10.9+ intel, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd99244d9d81f990bb3b29e1de1d033d58fae23963fc6667acc141facac896e4 |
|
MD5 | 4d99ace15c930588562c8f6011dc8ded |
|
BLAKE2b-256 | c38d1d90b089ab4a3d219bf1751902aa1d8faee1e91c16eb207119af6fcb4c22 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp36-cp36m-linux_armv7l.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp36-cp36m-linux_armv7l.whl
- Upload date:
- Size: 23.6 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70471029a9a5f5c5e72d539857f5a8f3f758f03f5c45cdfba413c3cb2e04f5e5 |
|
MD5 | dc41ff1510e17b793ce307144de2b5fd |
|
BLAKE2b-256 | 9e640b1121d9c34de7034ca844094bd4d327cf8aaea2a6cd131e303b6ed91327 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 17.4 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35a4676674ad7ecf40fdec8094fe92edfdd0eb57bd58772e0a157488136909d6 |
|
MD5 | b2dfc344bdb332ce9083be7d9c881b1b |
|
BLAKE2b-256 | 3a4aa1a4322ba1bdbb7c459d0e81a2befe9eb62c0b552d1971714b6a920e9bce |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp35-cp35m-win32.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp35-cp35m-win32.whl
- Upload date:
- Size: 15.3 kB
- Tags: CPython 3.5m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0372314c444d4430ddf85fba125c0d69fe1930bdd3b9df9710f97d1129be97ff |
|
MD5 | d75e85f6e83b1af3a9c2f598e13d32ef |
|
BLAKE2b-256 | 23d5c170bf81805fc50767950a45108b51aa94bf26474f90f72ef91a7946657a |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 14.2 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c57d8a49976bb6be5ab7aaba02dee264a92c8afc88eee46a91508b43afcec0b9 |
|
MD5 | 17d54103fdf73bf6daa4922615212d51 |
|
BLAKE2b-256 | de69e1a256d2c5f2b37f46483eaec9d2a149ddbff4b3af9a87966cd846851762 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp35-cp35m-manylinux1_i686.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp35-cp35m-manylinux1_i686.whl
- Upload date:
- Size: 14.5 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32d3d6a0bfecd21a80dc4a10067aac127397e76b12c7663b3ea1fce9567c0fe4 |
|
MD5 | e5756f598da7787bd130ad47446a2cac |
|
BLAKE2b-256 | e2e120af6470f3ea1b57e674dd57f42e3a7571d854137759c0e68a84e912d8a4 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
- Upload date:
- Size: 26.2 kB
- Tags: CPython 3.5m, macOS 10.10+ intel, macOS 10.10+ x86-64, macOS 10.6+ intel, macOS 10.9+ intel, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd430f4c558c6d19497748e918eff04da89955dc37828fd8c06392629c5969f9 |
|
MD5 | c6a39f5dd298a7da8c383a5e87a23b18 |
|
BLAKE2b-256 | 658ada2b40ffe6e29ab29b8236c205539068b3c37c5d50808bf372ba0b68f3a0 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp35-cp35m-linux_armv7l.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp35-cp35m-linux_armv7l.whl
- Upload date:
- Size: 30.0 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae3426986a38935e006b72ddf7c5564a80e00e1dc999c0c73b9c2c46ce80578c |
|
MD5 | 1bbc30c91f0187e7417f6486d2f294a9 |
|
BLAKE2b-256 | e22c4eedf04480680c9218d4660c55e1d51010a6fa1aa97082120ba4eab570d3 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp34-cp34m-win_amd64.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp34-cp34m-win_amd64.whl
- Upload date:
- Size: 15.4 kB
- Tags: CPython 3.4m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d3a6a71d2aeb41450f0f4c48fa5cf98d3bc4c426cf361916f4cac7ed03a57da |
|
MD5 | 8f675970343fa6a0aecf5009ea5a4106 |
|
BLAKE2b-256 | a41149f5f46404dbaa9813e35dc3c8bb334a536124dae06e33b93415e59d7b83 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp34-cp34m-win32.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp34-cp34m-win32.whl
- Upload date:
- Size: 15.2 kB
- Tags: CPython 3.4m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | added2386672ca89aa3d9278bedc414e92de44e78250fb38fbccf8c32b23784d |
|
MD5 | ccb9cd9ae231331b15c5ad1fa5ca3dcd |
|
BLAKE2b-256 | 38face785b509105ba5021475922fc762c5ffeeb1c7391bc745d5279803b5b66 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp34-cp34m-manylinux1_x86_64.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp34-cp34m-manylinux1_x86_64.whl
- Upload date:
- Size: 14.1 kB
- Tags: CPython 3.4m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e66e0f8da06a8c0562a309a4a92474ac8c275e0148bf1fd3ef23b27a67df361a |
|
MD5 | 806fc7614c10c817b0949c8c663dfc4e |
|
BLAKE2b-256 | c428274eb7ba82943a1ae3280575e3130f21a4fa0ac550464722c1c6c19b9799 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp34-cp34m-manylinux1_i686.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp34-cp34m-manylinux1_i686.whl
- Upload date:
- Size: 14.4 kB
- Tags: CPython 3.4m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3389d0ed82dc92616c4fded8ee8497f2e91b91e74997fd3bdd81ee85e57b097 |
|
MD5 | 5b051f40eb3762d70fa0995cdb3c5387 |
|
BLAKE2b-256 | 3ffbd442fe15acae0c6f54acc0ae91065f8a4dac1c983777d6a405c941b531b2 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
- Upload date:
- Size: 26.2 kB
- Tags: CPython 3.4m, macOS 10.10+ intel, macOS 10.10+ x86-64, macOS 10.6+ intel, macOS 10.9+ intel, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2874d4ee89a46157c470e350095aa5746c512c230c9e38182fdd161433f834d7 |
|
MD5 | 4e771a8f4a188524fda5a0f5580e5270 |
|
BLAKE2b-256 | d3819740dc9957c3badd54eef15331fe1b6fb26101297323212ef788620c73d2 |
Provenance
File details
Details for the file TgCrypto-1.0.3-cp34-cp34m-linux_armv7l.whl
.
File metadata
- Download URL: TgCrypto-1.0.3-cp34-cp34m-linux_armv7l.whl
- Upload date:
- Size: 29.6 kB
- Tags: CPython 3.4m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a8c74014ea4d5259aa58cd1e8ce0d12078e838d83bf9a953de653949ca32b29 |
|
MD5 | 185cb722e49761a068081bb07aca5e81 |
|
BLAKE2b-256 | 4a6d86599ec68b6c5f90065479ba67d252830283429865a11e9e9d009ba8a7ba |