Skip to main content

tgnet

Deserializes/serializes Telegram tgnet.dat format. Can be used to extract/replace authKey and dcId.

This is fork of batreller/telegram_android_session_converter with support of serialization and zero dependencies.

To convert the session all you need is just tgnet.dat file from the root directory of your telegram app on the phone, it's located at /data/data/org.telegram.messenger.web (or another package name, if you're using an unofficial client), it can be extracted using ADB (Android Debug Bridge).

Usage

from tgnet import Tgnet

tgnet_path = input("tgnet.dat path: ")

tgnet = Tgnet(tgnet_path)
current_dc = tgnet.get_current_datacenter()
auth_key = current_dc.get_auth_key_perm()

print(f"Current dc id: {current_dc.id}")
print(f"Auth key (hex): {auth_key.hex() if auth_key is not None else None}")

# Current dc id: 2
# Auth key (hex): '72a9808fb4a9e51e6ca57259714c14fa83546fc9d56fcb9d7de77c59fa13b6d6...'

Running tests

pytest -s -x --disable-warnings --cov=tgnet/ test.py

Metadata

Release files for tgnet 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tgnet 0.2.1
File Size Uploaded
tgnet-0.2.1.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tgnet 0.2.1
File Interpreter ABI Platform
tgnet-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.2 kB

Release files / tgnet-0.2.1.tar.gz

Download URL tgnet-0.2.1.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
22423d2f60e7dc7ff00aebd5a77d3ebccb4cadcf723d7935e4e9b01aa6c44c58
BLAKE2b-256 checksum
How to use checksums
82d24831cb695e0bb13cf7c397c408016cae591ac095e9c58a3f9347c1f280e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.14.2 Linux/6.17.12-300.fc43.x86_64

Release files / tgnet-0.2.1-py3-none-any.whl

Download URL tgnet-0.2.1-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b46a4f658e1ff26d8bd0660b96d6d626f2466302e57d3b601dc25d6b7bae313
BLAKE2b-256 checksum
How to use checksums
b1195163c969042e44cd96b10f8900740a661823f3d1bb6f9b19208ff8116f4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.14.2 Linux/6.17.12-300.fc43.x86_64

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page