from tgbox import loop
from tgbox.api import (
TelegramAccount,
make_remote_box,
make_local_box
)
from tgbox.keys import make_basekey
from getpass import getpass
async def main():
ta = TelegramAccount(
phone_number = input('Phone: ')
)
await ta.connect()
await ta.send_code_request()
await ta.sign_in(
code = int(input('Code: ')),
password = getpass('Pass: ')
)
basekey = make_basekey(b'very_bad_phrase')
erb = await make_remote_box(ta)
dlb = await make_local_box(erb, ta, basekey)
drb = await erb.decrypt(dlb=dlb)
ff = await dlb.make_file(
file = open('cats.png','rb'),
comment = b'Cats are cool B-)',
foldername = b'Pictures/Kitties'
)
drbfi = await drb.push_file(ff)
await drbfi.download()
loop.run_until_complete(main())
The Telegram is beautiful app. Not only by mean of features and Client API, but it's also 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, but there also can be plenty of "crypto-related" things.
This library targets to be a PoC of encrypted file storage inside Telegram, but can be used as standalone API.
We name "encrypted cloud storage" as Box and the API to it as Tgbox. There is two of boxes: 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). You can make unlimited amount of Boxes, upload speed equals to vanilla Telegram and maximum filesize is ~2GB-2MB
.
See ReadTheDocs for main information and help.
You can also build docs from the source
git clone https://github.com/NonProject/tgbox --branch=main
cd tgbox; python3 -m pip install -r requirements.txt
cd docs; make html; <your-browser> _build/html/index.html