diff --git a/pyrogram/client/session_storage/__init__.py b/pyrogram/client/session_storage/__init__.py index 6ee92ebc..ced103ce 100644 --- a/pyrogram/client/session_storage/__init__.py +++ b/pyrogram/client/session_storage/__init__.py @@ -19,3 +19,4 @@ from .session_storage_mixin import SessionStorageMixin from .base_session_storage import BaseSessionStorage, SessionDoesNotExist from .json_session_storage import JsonSessionStorage +from .string_session_storage import StringSessionStorage diff --git a/pyrogram/client/session_storage/string_session_storage.py b/pyrogram/client/session_storage/string_session_storage.py new file mode 100644 index 00000000..9b6ebf0e --- /dev/null +++ b/pyrogram/client/session_storage/string_session_storage.py @@ -0,0 +1,38 @@ +import base64 +import binascii +import struct + +from . import BaseSessionStorage, SessionDoesNotExist + + +def StringSessionStorage(print_session: bool = False): + class StringSessionStorageClass(BaseSessionStorage): + """ + Packs session data as following (forcing little-endian byte order): + Char dc_id (1 byte, unsigned) + Boolean test_mode (1 byte) + Long long user_id (8 bytes, signed) + Bytes auth_key (256 bytes) + + Uses Base64 encoding for printable representation + """ + PACK_FORMAT = '