Package: tgbox
This repository contains a set of classes and functions used to manage TGBOX.Try thetgbox-cliif you’re interested in working implementation!fromasyncioimportrunasasyncio_runfromgetpassimportgetpass# Hidden inputfromtgbox.apiimportTelegramClient,make_remotebox,make_localboxfromtgbox.keysimportPhrase,make_basekey# This two will not work. Get your own at https://my.telegram.orgAPI_ID,API_HASH=1234567,'00000000000000000000000000000000'# Simple progress callback to track upload/download statePROGRESS_CALLBACK=lambdac,t:print(round(c/t*100),'%')asyncdefmain():phone=input('Phone number: ')tc=TelegramClient(phone_number=phone,api_id=API_ID,api_hash=API_HASH)awaittc.connect()# Connecting to Telegramawaittc.send_code()# Requesting login codecode=int(input('Login code: '))password=getpass('Your password: ')# Login to your Telegram accountawaittc.log_in(password,code)# Generate and show your Box phraseprint(phrase:=Phrase.generate())# WARNING: This will use 1GB of RAM for a# couple of seconds. See help(make_basekey)basekey=make_basekey(phrase)erb=awaitmake_remotebox(tc)# Make EncryptedRemoteBoxdlb=awaitmake_localbox(erb,basekey)# Make DecryptedLocalBoxdrb=awaiterb.decrypt(dlb=dlb)# Obtain DecryptedRemoteBox# Write a file path to upload to your Boxfile_to_upload=input('File to upload (path): ')# Preparing for upload. Will return a PreparedFile objectpf=awaitdlb.prepare_file(open(file_to_upload,'rb'))# Uploading PreparedFile to Remote and getting DecryptedRemoteBoxFiledrbf=awaitdrb.push_file(pf,progress_callback=PROGRESS_CALLBACK)# Retrieving some info from the RemoteBox fileprint('File size:',drbf.size,'bytes')print('File name:',drbf.file_name)# You can also access all information about# the RemoteBoxFile you need from the LocalBoxdlbf=awaitdlb.get_file(drbf.id)print('File size:',dlbf.size,'bytes')print('File path:',dlbf.file_path)# Downloading your [already uploaded] file from Remote.awaitdrbf.download(progress_callback=PROGRESS_CALLBACK)awaitdrb.done()# Close all connectionsawaitdlb.done()# after work was doneasyncio_run(main())MotivationThe 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.TargetThis[unofficial]library targets to be a PoC ofencrypted file storageinside the Telegram, and should be used as standalonePython library.AbstractWe name“encrypted cloud storage”asBoxand the API to it astgbox. TheBoxsplits into theRemoteBoxand theLocalBox. They define a basic primitives. You canshareyourBoxand separateFileswith other people absolutelysecure- only You and someone you want will have decryption key, even through insecure communication canals (e2e). You can makeunlimitedamount of Boxes, Upload & Downloadspeed is fasterthan in official Telegram clients and maximum filesize is around2GBand around4GBfor Premium users.DocumentationSeeReadTheDocsfor main information and help.You can also build docs from the sourcegit 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.htmlThird party & thanks to⭐️Stargazers!Sphinx_book_theme(BSD 3-Clause)Aiosqlite(MIT)Telethon(MIT)Ecdsa(LICENSE)Filetype(MIT)Cryptg(LICENSE)Cryptography(LICENSE)ResourcesOfficialdeveloper channel:@nontgboxExampleTGBOXcontainer:@nontgbox_non