Skip to content

Instantly share code, notes, and snippets.

@WeslenPy
Last active February 11, 2025 02:41
Show Gist options
  • Save WeslenPy/81e648216c3181bd9476582b42adb058 to your computer and use it in GitHub Desktop.
Save WeslenPy/81e648216c3181bd9476582b42adb058 to your computer and use it in GitHub Desktop.
from urllib.parse import quote as urllib_quote
from consonance.structs.keypair import KeyPair
from wa.axt.factory import AxolotlManagerFactory
from wa.axt.manager import AxolotlManager
from wa.crypto import Cryptography
import uuid,random,struct,os,base64
class Token(Cryptography):
def generate(self,phone,cc='cc'):
_axolotl_manager:AxolotlManager = AxolotlManagerFactory().get_manager(phone, phone)
client_static_keypair = KeyPair.generate()
_in = str(phone)[len(str(cc)):]
e_keytype = self.b64encode(b"\x05")
authkey = self.b64encode(client_static_keypair.public.data)
e_regid = self.b64encode(struct.pack('>I', _axolotl_manager.registration_id))
e_ident= self.b64encode(_axolotl_manager.identity.publicKey.serialize()[1:])
signedprekey = _axolotl_manager.load_latest_signed_prekey(generate=True)
e_skey_id = self.b64encode(struct.pack('>I', signedprekey.getId())[1:])
e_skey_val = self.b64encode(signedprekey.getKeyPair().publicKey.serialize()[1:])
e_skey_sig= self.b64encode(signedprekey.getSignature())
token = self.getToken(_in)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment