mirror of
https://github.com/TeamPGM/tgcrypto.git
synced 2024-11-25 01:24:14 +00:00
Update README.md
This commit is contained in:
parent
30d5c739d9
commit
08a2c26236
50
README.rst
50
README.rst
@ -7,6 +7,10 @@ Table of Contents
|
||||
|
||||
- `Installation`_
|
||||
|
||||
- `API`_
|
||||
|
||||
- `Usage`_
|
||||
|
||||
- `Contribution`_
|
||||
|
||||
- `Feedback`_
|
||||
@ -39,6 +43,46 @@ what you should do next:
|
||||
- **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:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def ige_encrypt(data: bytes, key: bytes, iv: bytes) -> bytes:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def ige_decrypt(data: bytes, key: bytes, iv: bytes) -> bytes:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def ctr_encrypt(data: bytes, key: bytes, iv: bytes) -> bytes:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def ctr_decrypt(data: bytes, key: bytes, iv: bytes) -> bytes:
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
TgCrypto is as simple as this example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
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
|
||||
============
|
||||
|
||||
@ -106,3 +150,9 @@ License
|
||||
Community
|
||||
</a>
|
||||
</p>
|
||||
|
||||
.. |logo| image:: https://pyrogram.ml/images/tgcrypto_logo.png
|
||||
:target: https://github.com/pyrogram/tgcrypto
|
||||
:alt: TgCrypto
|
||||
|
||||
.. |description| replace:: **Telegram Crypto Library for Pyrogram**
|
Loading…
Reference in New Issue
Block a user