From 08a2c26236c96810593c20f1afd6f688c02ba25b Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 19 Feb 2018 14:48:05 +0100 Subject: [PATCH] Update README.md --- README.rst | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 0bfdfdb..dec58ce 100644 --- a/README.rst +++ b/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 ============ @@ -89,10 +133,10 @@ License
- +
Telegram Crypto Library for Pyrogram
-
+
Download
@@ -106,3 +150,9 @@ License
Community