Created
March 3, 2019 00:37
-
-
Save ohld/6648db94295618eeafbbe80c7ef8da29 to your computer and use it in GitHub Desktop.
Instagram Login Signing magic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid as uuid_library | |
import hmac | |
import json | |
import hashlib | |
import requests | |
import six.moves.urllib as urllib | |
def hex_digest(*args): | |
m = hashlib.md5() | |
m.update(b''.join([arg.encode('utf-8') for arg in args])) | |
return m.hexdigest() | |
def generate_device_id(seed): | |
volatile_seed = "12345" # Important ! :) :) | |
m = hashlib.md5() | |
m.update(seed.encode('utf-8') + volatile_seed.encode('utf-8')) | |
return 'android-' + m.hexdigest()[:16] | |
def generate_uuid(): | |
return str(uuid_library.uuid4()) | |
def generate_signature(data): | |
body = hmac.new(IG_SIG_KEY.encode('utf-8'), data.encode('utf-8'), | |
hashlib.sha256).hexdigest() + '.' + urllib.parse.quote(data) | |
signature = 'ig_sig_key_version=4&signed_body={body}' | |
return signature.format(body=body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment