I have the php code to generate 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. but I want these type of functionality in Javascript.
Can Any One Help Me. ?
Thanks in Advance.:)
I have the php code to generate 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. but I want these type of functionality in Javascript.
Can Any One Help Me. ?
Thanks in Advance.:)
Share edited Apr 28, 2016 at 14:51 Manquer 7,6478 gold badges45 silver badges71 bronze badges asked Jun 12, 2014 at 4:33 user3732525user3732525 271 silver badge3 bronze badges 1- 1 possible duplicate of Need HMAC SHA1 encryption library for javascript – cegfault Commented Jun 12, 2014 at 4:38
1 Answer
Reset to default 7there is no default functions but there are third party libarires that provide this functionality
- Crypto-js is a good library that provides this feature ( see https://code.google./p/crypto-js/#HMAC) for how to generate HMAC codes using this library)
Here is an example
<script src="http://crypto-js.googlecode./svn/tags/3.1.2/build/rollups/hmac-md5.js"></script>
<script src="http://crypto-js.googlecode./svn/tags/3.1.2/build/rollups/hmac-sha1.js"></script>
<script src="http://crypto-js.googlecode./svn/tags/3.1.2/build/rollups/hmac-sha256.js"></script>
<script src="http://crypto-js.googlecode./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,