imlewc
V2EX  ›  问与答

与 APP 交互的 API 怎么保证安全呢?

  •  
  •   imlewc · May 29, 2018 · 1377 views
  •   You need to sign in to view this topic
    This topic created in 3105 days ago, the information mentioned may be changed or developed.

    APP 启动的时候 调用注册 获取一个 APPID 以及 APP secret 再通过签名算法,列了个比较流行的签名算法

    • 对所有 API 请求参数(包括公共参数和业务参数,但除去 sign 参数和 byte[]类型的参数),根据参数名称的 ASCII 码表的顺序排序。如:foo:1, bar:2, foo_bar:3, foobar:4 排序后的顺序是 bar:2, foo:1, foo_bar:3, foobar:4。

    • 将排序好的参数名和参数值拼装在一起,根据上面的示例得到的结果为:bar2foo1foo_bar3foobar4。

    • 把拼装好的字符串采用 utf-8 编码,使用签名算法对编码后的字节流进行摘要。如果使用 MD5 算法,则需要在拼装的字符串前后加上 app 的 secret 后,再进行摘要,如:md5(secret+bar2foo1foo_bar3foobar4+secret);如果使用 HMAC_MD5 算法,则需要用 app 的 secret 初始化摘要算法后,再进行摘要,如:hmac_md5(bar2foo1foo_bar3foobar4)。

    • 将摘要得到的字节流结果使用十六进制表示,如:hex(“ helloworld ”.getBytes(“ utf-8 ”)) = “ 68656C6C6F776F726C64 ”

    假如 APP 被反编译了怎么破?? 我就能拿到你的各种逻辑了

    再问下 这种 APP 的数据加密方案,大家有什么好的建议

    deston
    deston
    May 29, 2018 via Android
    1
    用 https 不就好了?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2120 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 01:42 · PVG 09:42 · LAX 17:42 · JFK 20:42
    ♥ Do have faith in what you're doing.