Update README.md

This commit is contained in:
Dan 2018-02-19 14:48:05 +01:00
parent 30d5c739d9
commit 08a2c26236

View File

@ -7,6 +7,10 @@ Table of Contents
- `Installation`_ - `Installation`_
- `API`_
- `Usage`_
- `Contribution`_ - `Contribution`_
- `Feedback`_ - `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``). - **Linux**: Install a proper C compiler (``gcc``, ``clang``) and the Python header files (``python3-dev``).
- **Termux (Android)**: Install ``clang`` and ``python-dev`` packages. - **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 Contribution
============ ============
@ -89,10 +133,10 @@ License
<div><img src="https://pyrogram.ml/images/tgcrypto.png" alt="TgCrypto Logo"></div> <div><img src="https://pyrogram.ml/images/tgcrypto.png" alt="TgCrypto Logo"></div>
</a> </a>
</h1> </h1>
<p align="center"> <p align="center">
<b>Telegram Crypto Library for <a href="https://github.com/pyrogram/pyrogram">Pyrogram</a></b> <b>Telegram Crypto Library for <a href="https://github.com/pyrogram/pyrogram">Pyrogram</a></b>
<br> <br>
<a href="https://pypi.python.org/pypi/TgCrypto"> <a href="https://pypi.python.org/pypi/TgCrypto">
Download Download
@ -106,3 +150,9 @@ License
Community Community
</a> </a>
</p> </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**