在javascript中有任何方法来生成hash_hmac代码.(就像php中的hash_hmac一样)

use*_*525 3 javascript hash md5 cryptography

我有php代码来生成hash_hmac

$concate=array();
$validation_token = hash_hmac('md5', implode("|", $concate), 'hshalslkaslfhalkfhalsksaas');
echo $validation_token;
Run Code Online (Sandbox Code Playgroud)

所以现在$validation_token给我正确的价值.但我想在Javascript中使用这些类型的功能.

谁能帮我.?

提前致谢.:)

Man*_*uer 6

没有默认功能,但有第三方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>
Run Code Online (Sandbox Code Playgroud)

注意:库不是非常积极地维护,