tgbox


Nametgbox JSON
Version 1.3.1 PyPI version JSON
download
home_pagehttps://github.com/NonProjects/tgbox
SummaryEncrypted cloud storage Protocol based on a Telegram API
upload_time2023-09-09 19:30:40
maintainer
docs_urlNone
authorNonProjects
requires_python
licenseLGPL-2.1
keywords telegram cloud-storage cloud api asyncio non-official
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            TGBOX: encrypted cloud storage based on Telegram
================================================
.. epigraph::
        | This repository contains a set of classes and functions used to manage TGBOX.
        | Try the `tgbox-cli <https://github.com/NotStatilko/tgbox-cli>`__  if you're interested in working implementation!

.. code-block:: python

        from asyncio import run as asyncio_run
        from getpass import getpass # Hidden input

        from tgbox.api import TelegramClient, make_remotebox, make_localbox
        from tgbox.keys import Phrase, make_basekey

        # This two will not work. Get your own at https://my.telegram.org
        API_ID, API_HASH = 1234567, '00000000000000000000000000000000'

        # Simple progress callback to track upload/download state
        PROGRESS_CALLBACK = lambda c,t: print(round(c/t*100),'%')

        async def main():
            phone = input('Phone number: ')

            tc = TelegramClient(
                phone_number = phone,
                api_id = API_ID,
                api_hash = API_HASH
            )
            await tc.connect() # Connecting to Telegram
            await tc.send_code() # Requesting login code

            code = int(input('Login code: '))
            password = getpass('Your password: ')

            # Login to your Telegram account
            await tc.log_in(password, code)

            # Generate and show your Box phrase
            print(phrase := Phrase.generate())

            # WARNING: This will use 1GB of RAM for a
            # couple of seconds. See help(make_basekey)
            basekey = make_basekey(phrase)

            erb = await make_remotebox(tc) # Make EncryptedRemoteBox
            dlb = await make_localbox(erb, basekey) # Make DecryptedLocalBox
            drb = await erb.decrypt(dlb=dlb) # Obtain DecryptedRemoteBox

            # Write a file path to upload to your Box
            file_to_upload = input('File to upload (path): ')

            # Preparing for upload. Will return a PreparedFile object
            pf = await dlb.prepare_file(open(file_to_upload,'rb'))

            # Uploading PreparedFile to Remote and getting DecryptedRemoteBoxFile
            drbf = await drb.push_file(pf, progress_callback=PROGRESS_CALLBACK)

            # Retrieving some info from the RemoteBox file
            print('File size:', drbf.size, 'bytes')
            print('File name:', drbf.file_name)

            # You can also access all information about
            # the RemoteBoxFile you need from the LocalBox
            dlbf = await dlb.get_file(drbf.id)

            print('File size:', dlbf.size, 'bytes')
            print('File path:', dlbf.file_path)

            # Downloading your [already uploaded] file from Remote.
            await drbf.download(progress_callback=PROGRESS_CALLBACK)

            await drb.done() # Close all connections
            await dlb.done() # after work was done

        asyncio_run(main())

Motivation
----------

The Telegram is beautiful app. Not only by mean of features and Client API, but it's also used to be good in cryptography and secure messaging. In the last years, core and client devs of Telegram mostly work for "social-network features", i.e video chats and message reactions which is OK (until stories, wtf?), but there also can be plenty of "crypto-related" things implemented.

Target
------

This *[unofficial]* library targets to be a PoC of **encrypted file storage** inside the Telegram, and should be used as standalone *Python library*.

Abstract
--------

We name *"encrypted cloud storage"* as **Box** and the API to it as ``tgbox``. The *Box* splits into the **RemoteBox** and the **LocalBox**. They define a basic primitives. You can **share** your *Box* and separate *Files* with other people absolutely **secure** - only You and someone you want will have decryption key, even through insecure communication canals (`e2e <https://en.wikipedia.org/wiki/End-to-end_encryption>`__). You can make **unlimited** amount of Boxes, Upload & Download **speed is faster** than in official Telegram clients and maximum filesize is around **2GB** and around **4GB** for Premium users.

Documentation
-------------

See `ReadTheDocs <https://tgbox.readthedocs.io/>`__ for main information and help.

You can also build docs from the source

.. code-block:: console

   git clone https://github.com/NonProject/tgbox --branch=indev
   cd tgbox && python3 -m pip install .[doc] # Install with doc
   cd docs && make html && firefox _build/html/index.html

Third party & thanks to
-----------------------
- `⭐️ <https://github.com/NonProjects/tgbox/stargazers>`__ **Stargazers!**
- `Sphinx_rtd_theme <https://github.com/readthedocs/sphinx_rtd_theme>`__ (`MIT <https://github.com/readthedocs/sphinx_rtd_theme/blob/master/LICENSE>`__)
- `Aiosqlite <https://github.com/omnilib/aiosqlite>`__ (`MIT <https://github.com/omnilib/aiosqlite/blob/main/LICENSE>`__)
- `Telethon <https://github.com/LonamiWebs/Telethon>`__ (`MIT <https://github.com/LonamiWebs/Telethon/blob/master/LICENSE>`__)
- `Ecdsa <https://github.com/tlsfuzzer/python-ecdsa>`__ (`LICENSE <https://github.com/tlsfuzzer/python-ecdsa/blob/master/LICENSE>`__)
- `Filetype <https://github.com/h2non/filetype.py>`__ (`MIT <https://github.com/h2non/filetype.py/blob/master/LICENSE>`__)
- `Cryptg <https://github.com/cher-nov/cryptg>`__ (`LICENSE <https://github.com/cher-nov/cryptg/blob/master/LICENSE.txt>`__)
- `Cryptography <https://github.com/pyca/cryptography>`__ (`LICENSE <https://github.com/pyca/cryptography/blob/main/LICENSE>`__)

Resources
---------
- Official **developer channel**: `@nontgbox <https://telegram.me/nontgbox>`__
- **Example** TGBOX **container**: `@nontgbox_non <https://telegram.me/nontgbox_non>`__



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NonProjects/tgbox",
    "name": "tgbox",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Telegram,Cloud-Storage,Cloud,API,Asyncio,Non-official",
    "author": "NonProjects",
    "author_email": "thenonproton@pm.me",
    "download_url": "https://files.pythonhosted.org/packages/e2/32/ece696f7a1cc9fc284602ad1d1314b16d7d39d1776af61fe87b3e062369e/tgbox-1.3.1.tar.gz",
    "platform": null,
    "description": "TGBOX: encrypted cloud storage based on Telegram\n================================================\n.. epigraph::\n        | This repository contains a set of classes and functions used to manage TGBOX.\n        | Try the `tgbox-cli <https://github.com/NotStatilko/tgbox-cli>`__  if you're interested in working implementation!\n\n.. code-block:: python\n\n        from asyncio import run as asyncio_run\n        from getpass import getpass # Hidden input\n\n        from tgbox.api import TelegramClient, make_remotebox, make_localbox\n        from tgbox.keys import Phrase, make_basekey\n\n        # This two will not work. Get your own at https://my.telegram.org\n        API_ID, API_HASH = 1234567, '00000000000000000000000000000000'\n\n        # Simple progress callback to track upload/download state\n        PROGRESS_CALLBACK = lambda c,t: print(round(c/t*100),'%')\n\n        async def main():\n            phone = input('Phone number: ')\n\n            tc = TelegramClient(\n                phone_number = phone,\n                api_id = API_ID,\n                api_hash = API_HASH\n            )\n            await tc.connect() # Connecting to Telegram\n            await tc.send_code() # Requesting login code\n\n            code = int(input('Login code: '))\n            password = getpass('Your password: ')\n\n            # Login to your Telegram account\n            await tc.log_in(password, code)\n\n            # Generate and show your Box phrase\n            print(phrase := Phrase.generate())\n\n            # WARNING: This will use 1GB of RAM for a\n            # couple of seconds. See help(make_basekey)\n            basekey = make_basekey(phrase)\n\n            erb = await make_remotebox(tc) # Make EncryptedRemoteBox\n            dlb = await make_localbox(erb, basekey) # Make DecryptedLocalBox\n            drb = await erb.decrypt(dlb=dlb) # Obtain DecryptedRemoteBox\n\n            # Write a file path to upload to your Box\n            file_to_upload = input('File to upload (path): ')\n\n            # Preparing for upload. Will return a PreparedFile object\n            pf = await dlb.prepare_file(open(file_to_upload,'rb'))\n\n            # Uploading PreparedFile to Remote and getting DecryptedRemoteBoxFile\n            drbf = await drb.push_file(pf, progress_callback=PROGRESS_CALLBACK)\n\n            # Retrieving some info from the RemoteBox file\n            print('File size:', drbf.size, 'bytes')\n            print('File name:', drbf.file_name)\n\n            # You can also access all information about\n            # the RemoteBoxFile you need from the LocalBox\n            dlbf = await dlb.get_file(drbf.id)\n\n            print('File size:', dlbf.size, 'bytes')\n            print('File path:', dlbf.file_path)\n\n            # Downloading your [already uploaded] file from Remote.\n            await drbf.download(progress_callback=PROGRESS_CALLBACK)\n\n            await drb.done() # Close all connections\n            await dlb.done() # after work was done\n\n        asyncio_run(main())\n\nMotivation\n----------\n\nThe Telegram is beautiful app. Not only by mean of features and Client API, but it's also used to be good in cryptography and secure messaging. In the last years, core and client devs of Telegram mostly work for \"social-network features\", i.e video chats and message reactions which is OK (until stories, wtf?), but there also can be plenty of \"crypto-related\" things implemented.\n\nTarget\n------\n\nThis *[unofficial]* library targets to be a PoC of **encrypted file storage** inside the Telegram, and should be used as standalone *Python library*.\n\nAbstract\n--------\n\nWe name *\"encrypted cloud storage\"* as **Box** and the API to it as ``tgbox``. The *Box* splits into the **RemoteBox** and the **LocalBox**. They define a basic primitives. You can **share** your *Box* and separate *Files* with other people absolutely **secure** - only You and someone you want will have decryption key, even through insecure communication canals (`e2e <https://en.wikipedia.org/wiki/End-to-end_encryption>`__). You can make **unlimited** amount of Boxes, Upload & Download **speed is faster** than in official Telegram clients and maximum filesize is around **2GB** and around **4GB** for Premium users.\n\nDocumentation\n-------------\n\nSee `ReadTheDocs <https://tgbox.readthedocs.io/>`__ for main information and help.\n\nYou can also build docs from the source\n\n.. code-block:: console\n\n   git clone https://github.com/NonProject/tgbox --branch=indev\n   cd tgbox && python3 -m pip install .[doc] # Install with doc\n   cd docs && make html && firefox _build/html/index.html\n\nThird party & thanks to\n-----------------------\n- `\u2b50\ufe0f <https://github.com/NonProjects/tgbox/stargazers>`__ **Stargazers!**\n- `Sphinx_rtd_theme <https://github.com/readthedocs/sphinx_rtd_theme>`__ (`MIT <https://github.com/readthedocs/sphinx_rtd_theme/blob/master/LICENSE>`__)\n- `Aiosqlite <https://github.com/omnilib/aiosqlite>`__ (`MIT <https://github.com/omnilib/aiosqlite/blob/main/LICENSE>`__)\n- `Telethon <https://github.com/LonamiWebs/Telethon>`__ (`MIT <https://github.com/LonamiWebs/Telethon/blob/master/LICENSE>`__)\n- `Ecdsa <https://github.com/tlsfuzzer/python-ecdsa>`__ (`LICENSE <https://github.com/tlsfuzzer/python-ecdsa/blob/master/LICENSE>`__)\n- `Filetype <https://github.com/h2non/filetype.py>`__ (`MIT <https://github.com/h2non/filetype.py/blob/master/LICENSE>`__)\n- `Cryptg <https://github.com/cher-nov/cryptg>`__ (`LICENSE <https://github.com/cher-nov/cryptg/blob/master/LICENSE.txt>`__)\n- `Cryptography <https://github.com/pyca/cryptography>`__ (`LICENSE <https://github.com/pyca/cryptography/blob/main/LICENSE>`__)\n\nResources\n---------\n- Official **developer channel**: `@nontgbox <https://telegram.me/nontgbox>`__\n- **Example** TGBOX **container**: `@nontgbox_non <https://telegram.me/nontgbox_non>`__\n\n\n",
    "bugtrack_url": null,
    "license": "LGPL-2.1",
    "summary": "Encrypted cloud storage Protocol based on a Telegram API",
    "version": "1.3.1",
    "project_urls": {
        "Download": "https://github.com/NonProjects/tgbox/archive/refs/tags/v1.3.1.tar.gz",
        "Homepage": "https://github.com/NonProjects/tgbox"
    },
    "split_keywords": [
        "telegram",
        "cloud-storage",
        "cloud",
        "api",
        "asyncio",
        "non-official"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e67c9fc78dcc2a029a1eba410fc91dc225ccabcb4aac643f8f5e561fdb128f81",
                "md5": "68a4c461d6cf51b8da6e441bed0cbcf8",
                "sha256": "be966f9a730feb45ccbaf63e52adb52c0581f0c8e393b01bd0e966f96f52aeda"
            },
            "downloads": -1,
            "filename": "tgbox-1.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "68a4c461d6cf51b8da6e441bed0cbcf8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 107152,
            "upload_time": "2023-09-09T19:30:37",
            "upload_time_iso_8601": "2023-09-09T19:30:37.207838Z",
            "url": "https://files.pythonhosted.org/packages/e6/7c/9fc78dcc2a029a1eba410fc91dc225ccabcb4aac643f8f5e561fdb128f81/tgbox-1.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e232ece696f7a1cc9fc284602ad1d1314b16d7d39d1776af61fe87b3e062369e",
                "md5": "768c61873815ab09cc4bcc17e49aa4b5",
                "sha256": "b13bb5373ab3df0b3db1408f7025134231fd73880cd84ccab55ac79358a88262"
            },
            "downloads": -1,
            "filename": "tgbox-1.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "768c61873815ab09cc4bcc17e49aa4b5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 97612,
            "upload_time": "2023-09-09T19:30:40",
            "upload_time_iso_8601": "2023-09-09T19:30:40.022290Z",
            "url": "https://files.pythonhosted.org/packages/e2/32/ece696f7a1cc9fc284602ad1d1314b16d7d39d1776af61fe87b3e062369e/tgbox-1.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-09 19:30:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NonProjects",
    "github_project": "tgbox",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "tgbox"
}
        
Elapsed time: 0.13064s