The openssl package available in most linux distributions include a way of creating the HMAC-SHA1 string from the command line…
echo -n "string to sign" | openssl dgst -sha1 -hmac "my secret key"
(stdin)= a993876ea1218921a1c8551923473da7b310dfae
C\
Encoding encoding = Encoding.UTF8;
byte[] secretBytes = encoding.GetBytes(“my secret key”);
HMACSHA1 hmacsha1 = new HMACSHA1(secretBytes);
hmacsha1.ComputeHash(encoding.GetBytes(“string to sign”));
byte[] data = hmacsha1.Hash;
Javascript
Cryptographic functions are available from the CryptJS libaray at .
var stringToSign = “string to sign”;
var secret = “my secret key”;
var signature = CryptoJS.HmacSHA1(stringToSign, secret);
NodeJS
This code assumes you have the crypto-js library installed (npm install crypto-js)
$ cat hmacsha1.js
var CryptoJS = require('crypto-js'),
message = "string to sign",
secret = "my secret key",
sig = CryptoJS.HmacSHA1(message, secret);
console.log("" + sig);
$ node hmacsha1.js
a993876ea1218921a1c8551923473da7b310dfae
Objective-C
HMAC-SHA1 functionality can be be included in IOS code by first adding the CommonCrypto library to your target, and including the following function in your appDelegate (or appropriate class)