mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 05:19:41 +00:00
Totally refactored source files location
Now it *should* be easier to turn Telethon into a pip package
This commit is contained in:
22
telethon/crypto/auth_key.py
Executable file
22
telethon/crypto/auth_key.py
Executable file
@@ -0,0 +1,22 @@
|
||||
from telethon.utils import BinaryWriter, BinaryReader
|
||||
import telethon.helpers as utils
|
||||
|
||||
|
||||
class AuthKey:
|
||||
def __init__(self, data):
|
||||
self.key = data
|
||||
|
||||
with BinaryReader(utils.sha1(self.key)) as reader:
|
||||
self.aux_hash = reader.read_long(signed=False)
|
||||
reader.read(4)
|
||||
self.key_id = reader.read_long(signed=False)
|
||||
|
||||
def calc_new_nonce_hash(self, new_nonce, number):
|
||||
"""Calculates the new nonce hash based on the current class fields' values"""
|
||||
with BinaryWriter() as writer:
|
||||
writer.write(new_nonce)
|
||||
writer.write_byte(number)
|
||||
writer.write_long(self.aux_hash, signed=False)
|
||||
|
||||
new_nonce_hash = utils.calc_msg_key(writer.get_bytes())
|
||||
return new_nonce_hash
|
Reference in New Issue
Block a user