Skip to content

Instantly share code, notes, and snippets.

@codethereforam
Created December 27, 2018 03:11
Show Gist options
  • Save codethereforam/7e3879aebcde289779ebe8715e4f30be to your computer and use it in GitHub Desktop.
Save codethereforam/7e3879aebcde289779ebe8715e4f30be to your computer and use it in GitHub Desktop.
使用API key做接口签名校验

使用API key做接口签名校验

参考

微信支付

要点

  1. 使用消息认证码而不是单向散列函数,即使用hmac(data, key)而不是hash(data+key)
  2. 使用安全的Hash函数,即选择SHA-2、SHA-3等,而不是MD5等
  3. 防止密钥推测攻击,密钥使用密码学安全的、高强度的伪随机数生成器生成,至少32字符
  4. 防止重放攻击,使用nonce等方式
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment