I have a code in PHP and that is below when i Execute the Below PHP code and when i Run the C# code which is below PHP Code i got different Result I dont know where I am wrong.
$accessID = "member-1681fca809";
$secretKey = "63f22236ab43b69462b3272b110e3c78";
$expires = 1357039353;
$stringToSign = $accessID."\n".$expires;
$binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);
$urlSafeSignature = urlencode(base64_encode($binarySignature));
print_r($expires);
print_r($urlSafeSignature);
I got Output
1357039353
M1PZW2DYVzdRV1l4ZHBPAmiv9iM%3D
While I run same code in c# i got different Output
string accessid = "member-1681fca809";
string secretekey = "63f22236ab43b69462b3272b110e3c78";
int Expire = 1357039353;
string stringTosign = accessid + Environment.NewLine + Expire;
byte[] secret = UTF8Encoding.UTF8.GetBytes(secretekey);
HMACSHA1 myhmacsha1 = new HMACSHA1(secret);
byte[] byteArray = Encoding.ASCII.GetBytes(stringTosign);
MemoryStream stream = new MemoryStream(byteArray);
byte[] hashValue = myhmacsha1.ComputeHash(stream);
string k = Convert.ToBase64String(Encoding.ASCII.GetBytes(hashValue.ToString()));
console.WriteLine(Expire);
console.WriteLine(k);
I Got OutPut
1357039353
U3lzdGVtLkJ5dGVbXQ==
U3lzdGVtLkJ5dGVbXQ==decodes toSystem.Byte[]Environment.NewLineit could be\r\n!