First, in python, you can simply use the hmac
module:
>>> import hmac
>>> hmac.new("9T5zhB4sTNGxMJ-iDdO-Ow"+"8rdp7erdig0m6aa72lhanvuk01"+"pizza1", "1387797294").hexdigest()
'9036a1a3f654aefeab426e9f7e17288e'
Second, your C# code does not implement the HMAC algorithm, but simply returns a MD5 hash. The python equivalent would be simply
>>> import md5
>>> md5.new("1387797294" + "9T5zhB4sTNGxMJ-iDdO-Ow"+"8rdp7erdig0m6aa72lhanvuk01"+"pizza1").hexdigest()
'8280c9a3804b53792324b62363fc22fd'
You can find an implemention of the HMAC algorithm in C# e.g. at CodePlex.
From the project page:
Project Description
This is a simple implementation of the MD5 cryptographic hashing algorithm and HMAC-MD5. This class consists of fully transparent C# code, suitable for use in .NET, Silverlight and WP7 applications.
Also, here's another simple implementation I've come up with:
string key = "9T5zhB4sTNGxMJ-iDdO-Ow" + "8rdp7erdig0m6aa72lhanvuk01" + "pizza1";
string message = "1387797294";
var encoding = Encoding.UTF8;
var md = System.Security.Cryptography.MD5CryptoServiceProvider.Create();
var trans_5C = new byte[64];
var trans_36 = new byte[64];
var b_key = encoding.GetBytes(key);
// TODO: also check if key is to short
if (b_key.Length > 64)
b_key = md.ComputeHash(b_key);
for (int i = 0; i < 64; i++)
{
trans_5C[i] = 92;
trans_36[i] = 54;
if (i < key.Length)
{
trans_5C[i] ^= b_key[i];
trans_36[i] ^= b_key[i];
}
}
byte[] inner = md.ComputeHash(trans_36.Concat(encoding.GetBytes(message)).ToArray());
var hash = md.ComputeHash(trans_5C.Concat(inner).ToArray());
StringBuilder sb = new StringBuilder();
foreach (byte b in hash)
sb.Append(b.ToString("x2"));
var result = sb.ToString(); // = 9036a1a3f654aefeab426e9f7e17288e