Links

账户和调用加密

94ETH API通用加密方法
为了保护用户资产安全,所有API调用都需要加密验证.
接入94ETH API, 加密步骤如下:

获取账户ID, Secret

登录工具站,获取账户ID和key, secret

生成加密原文

获取API full path

API full path是除去https://api.94eth.com/api前缀后剩下的full path(包括query参数)
例如, 撤销收款订单API:
https://api.94eth.com/api/api/cancel_order?order_id=4
去除前缀后为:
/api/cancel_order?order_id=4

添加认证参数

在上一步full path后添加account id, key, secret, timestamp, uniq:
account=${account id}&timestamp=${timestamp}&key=${key}&encrypt=${secret}&uniq=${uniq}
  • account id
账户id
  • key, secret
认证参数
  • timestamp
Unix time in Seconds, 如果timestamp与服务器时间相差过大,调用非法
  • uniq
调用者提供的一个数字, 在account粒度的所有api调用, 同一个uniq值不能在三分钟内重复出现, 防止重放攻击.
继续上个例子,添加认证参数后, url变成: [注意secret填入的key为encrypt]
/api/cancel_order?order_id=4&account=3&timestamp=1559623671&key=fedd9a91-3bc3-44b1-85f6-d4d315acac28&encrypt=3d25e631c3482288ff885663d48721eb&uniq=4510

生成加密值,替换secret

生成加密值

对上一步生成的原文进行哈希,生成加密值m
m = MD5(url)

替换secret

用加密得到的密文替换原url中的secret值

调用API

用最后得到的url发出API调用
https://www.94eth.com/api/api/load_eth_bill_addr?account=1&timestamp=1559623671&key=fedd9a91-3bc3-44b1-85f6-d4d315acac28&encrypt=3d25e631c34822885663d48721eb&uniq=4510