![](/img/trans.png)
[英]Is there any equivalent JavaScript function for PHP`s hash_hmac()?
[英]is there any method in javascript to genetare hash_hmac code. (Just like hash_hmac in php)
我有php代码来生成hash_hmac
$concate=array();
$validation_token = hash_hmac('md5', implode("|", $concate), 'hshalslkaslfhalkfhalsksaas');
echo $validation_token;
所以现在$validation_token
给了我正确的值。 但我想在Javascript中使用这些类型的功能。
谁能帮我。 ?
提前致谢。:)
没有默认功能,但有第三方libarires提供此功能
这是一个例子
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-md5.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha1.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha256.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha512.js"></script>
<script>
var hash = CryptoJS.HmacMD5("Message", "Secret Passphrase");
var hash = CryptoJS.HmacSHA1("Message", "Secret Passphrase");
var hash = CryptoJS.HmacSHA256("Message", "Secret Passphrase");
var hash = CryptoJS.HmacSHA512("Message", "Secret Passphrase");
</script>
注意:库不是非常积极地维护,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.