Created
May 31, 2019 04:45
-
-
Save Witawat/5acd84c9bfae2e43df98839c7d764fba to your computer and use it in GitHub Desktop.
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 binascii | |
import hashlib | |
import hmac | |
def genSigninRequestOtpSignature(signinType, deviceId, timestamp): | |
""" | |
url: "https://mobile-api-gateway.truemoney.com/mobile-api-gateway/api/v1/login/otp/" | |
headers: | |
username => str (ex: "09XXXXXXXX") | |
password => str (ex: "da39a3ee5e6b4b0d3255bfef95601890afd80709") | |
User-Agent => str (ex: "okhttp/3.12.0") | |
Content-Type => str (ex: "application/json") | |
params: | |
device_version => str (ex: "8.1.0") | |
app_name => str (ex: "wallet") | |
device_id => str (ex: "c394ddef21e24ed1910bd5b102b23706") | |
app_version => str (ex: "4.20.4") | |
device_type => str (ex: "ASUS_Z010D") | |
device_os => str (ex: "android") | |
json: | |
device_id => str (ex: "bb0b4a65077f7385") [deviceId] | |
signature => str (ex: "358b60c1fbeed96cb7267e8e5e76876f947bf4bc") | |
timestamp => str (ex: "1557465220750") [timestamp] | |
type => str (ex: "mobile") [signinType] | |
""" | |
secretKey = "9LXAVCxcITaABNK48pAVgc4muuTNJ4enIKS5YzKyGZ" | |
secretMessage = "{0}|{1}|{2}".format(signinType, deviceId, timestamp) | |
digester = hmac.new(secretKey.encode(), secretMessage.encode(), hashlib.sha1) | |
signature = binascii.hexlify(digester.digest()).decode() | |
return signature | |
def genSigninVerifyOtpSignature(signinType, otpCode, mobileNumber, otpRef, deviceId, mobileTracking, timestamp): | |
""" | |
url: "https://mobile-api-gateway.truemoney.com/mobile-api-gateway/api/v1/login/otp/verification/" | |
headers: | |
username => str (ex: "09XXXXXXXX") | |
password => str (ex: "da39a3ee5e6b4b0d3255bfef95601890afd80709") | |
User-Agent => str (ex: "okhttp/3.12.0") | |
Content-Type => str (ex: "application/json") | |
params: | |
device_version => str (ex: "8.1.0") | |
app_name => str (ex: "wallet") | |
device_id => str (ex: "c394ddef21e24ed1910bd5b102b23706") | |
app_version => str (ex: "4.20.4") | |
device_type => str (ex: "ASUS_Z010D") | |
device_os => str (ex: "android") | |
json: | |
device_id => str (ex: "bb0b4a65077f7385") [deviceId] | |
mobile_number => str (ex: "09XXXXXXXX") [mobileNumber] | |
mobile_tracking => str (ex: "m8J9IpbfSBZY3Kc4AYhUMriZrZa1jqZT5EdJp9LJFcv/OAaZagEAAA==") [mobileTracking] | |
otp_code => str (ex: "123456") [otpCode] | |
otp_reference => str (ex: "ABCD") [otpRef] | |
signature => str (ex: "77cc91113efbcea99ea0d5b5450f3d159694d6a2") | |
timestamp => str (ex: "1557465220750") [timestamp] | |
type => str (ex: "mobile") [signinType] | |
""" | |
secretKey = "9LXAVCxcITaABNK48pAVgc4muuTNJ4enIKS5YzKyGZ" | |
secretMessage = "{0}|{1}|{2}|{3}|{4}|{5}|{6}".format(signinType, otpCode, mobileNumber, otpRef, deviceId, mobileTracking, timestamp) | |
digester = hmac.new(secretKey.encode(), secretMessage.encode(), hashlib.sha1) | |
signature = binascii.hexlify(digester.digest()).decode() | |
return signature |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment