签名算法

> > 接口中所有字段(包括可选字段)都需要加入验签。 > 可选的意思 > 是参数值可以为空,但是验签必须加入. > # 1 签名算法 ## 1.1 准备好,我司提供的app_id与app_secret 例: app_id=testapp app_secret=hakqyzbsk7qg2176sksi128 ## 1.2 生成当前时间戳timestamp=now和唯一随机字符串nonce=random 注:唯一是相对于timestamp而言。 例: timestamp=1598591908509 nonce=wlayxs ## 1.3 按照请求参数名的字母升序排列非空请求参数(包含app_id) > `注意` 要做UrlEncode。 例: query="app_id=testapp&abc=hello&border=world&class=test&timestamp=1598591908509&nonce=wlayxs"; ## 1.4 拼接密钥app_secret queryToSign = query + "&app_secret=hakqyzbsk7qg2176sksi128"; ## 1.5 MD5并转换为大写 sign=MD5(queryToSign).toUpperCase(); ## 1.6 最终请求 url = query + "&sign=" + sign 例:http://api.test.com/test?app_id=xxxxxx&abc=hello&border=world&class=test&timestamp=1234567890123&nonce=wlayxs&sign=sign;