------------ js --------------

<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/hmac-sha256.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/enc-base64-min.js"></script>

<script>
  var hash = CryptoJS.HmacSHA256("Message", "secret");
  var hashInBase64 = CryptoJS.enc.Base64.stringify(hash);
  document.write(hashInBase64);
</script>

------------- php ----------------

$s = hash_hmac('sha256', 'Message', 'secret', true);
echo base64_encode($s);

------------ go ------------------

func ComputeHmac256(message string, secret string) string {
    key := []byte(secret)
    h := hmac.New(sha256.New, key)
    h.Write([]byte(message))
    return base64.StdEncoding.EncodeToString(h.Sum(nil))
}

func main() {
    fmt.Println(ComputeHmac256("Message", "secret"))
}

通过网盘分享的文件:海康相关

链接: https://pan.baidu.com/s/1HFi-LUVvfEmJsSiNkX43Bg 提取码: 48y8

标签: none

添加新评论