# MidasPay Signature
Take the interface of checking balances as an example
- Original request information
- Midas Key: zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u
- HTTP request method: POST
- The requested URI: /cgi-bin/midas/getbalance
- Sig signature
- Participate in Midas signature request parameters
"openid":"odkx20ENSNa2w5y3g_qOkOvBNM1g",
"appid":"wx1234567",
"offer_id":"12345678",
"ts":1507530737,
"zone_id":"1",
"pf":"android"
- The parameters participating in MidasPay signature are sorted in key=value format and in ascending order according to the parameter name ASCII lexicographic order, as follows:
stringA="appid=wx1234567&offer_id=12345678&openid=odkx20ENSNa2w5y3g_qOkOvBNM1g&pf=android&ts=1507530737&zone_id=1"
- Splice uri, method, and Midas key:
stringSignTemp=stringA+"&org_loc=/cgi-bin/midas/getbalance&method=POST&secret=zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u"
- Use Midas key as the key, and use HMAC-SHA256 to get the signature.
sig=hmac_sha256(key,stringSignTemp)
="1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b"
- mp_sig signature
- Participate in MP signature request parameters
"access_token":"ACCESSTOKEN",
"openid":"odkx20ENSNa2w5y3g_qOkOvBNM1g",
"appid":"wx1234567",
"offer_id":"12345678",
"ts":1507530737,
"zone_id":"1",
"pf":"android",
"sig":"1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b"
- The parameters participating in MP signature are sorted in key=value format and in ascending order according to the parameter name ASCII lexicographic order, as follows:
stringA="access_token=ACCESSTOKEN&appid=wx1234567&offer_id=12345678&openid=odkx20ENSNa2w5y3g_qOkOvBNM1g&pf=android&sig=1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b&ts=1507530737&zone_id=1"
- Splice uri, method, and session_key:
stringSignTemp=stringA+"&org_loc=/cgi-bin/midas/getbalance&method=POST&session_key=V7Q38/i2KXaqrQyl2Yx9Hg=="
- Use session_key as the key, and use HMAC-SHA256 to get the signature.
mp_sig=hmac_sha256(key,stringSignTemp)
="ff4c5bb39dea1002a8f03be0438724e1a8bcea5ebce8f221f9b9fea3bcf3bf76"