简体   繁体   English

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

[英]is there any method in javascript to genetare hash_hmac code. (Just like hash_hmac in php)

I have the php code to generate hash_hmac 我有php代码来生成hash_hmac

$concate=array();
$validation_token = hash_hmac('md5', implode("|", $concate), 'hshalslkaslfhalkfhalsksaas');
echo $validation_token;

so now $validation_token is giving me the correct value. 所以现在$validation_token给了我正确的值。 but I want these type of functionality in Javascript. 但我想在Javascript中使用这些类型的功能。

Can Any One Help Me. 谁能帮我。 ?

Thanks in Advance.:) 提前致谢。:)

there is no default functions but there are third party libarires that provide this functionality 没有默认功能,但有第三方libarires提供此功能

Here is an example 这是一个例子

<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>

Note: The library is not very actively maintained, 注意:库不是非常积极地维护,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM