Your cryptographic code does not work. :-)
Code Samples
, " HMAC-SHA256 UTF-8 Base64". hashKey " " Azure, toSign " " docs.
Windows Phone 8.1
Windows Phone 8.1 Windows.Security.Cryptography :
public string GetEncodedSignature(string toSign, string hashKey)
{
var utf8 = BinaryStringEncoding.Utf8;
var msgBuffer = CryptographicBuffer.ConvertStringToBinary(toSign, utf8);
var keyBuffer = CryptographicBuffer.DecodeFromBase64String(hashKey);
var alg = MacAlgorithmNames.HmacSha256;
var objMacProv = MacAlgorithmProvider.OpenAlgorithm(alg);
CryptographicHash hash = objMacProv.CreateHash(keyBuffer);
hash.Append(msgBuffer);
IBuffer hashMsg = hash.GetValueAndReset();
var result = CryptographicBuffer.EncodeToBase64String(hashMsg);
return result;
}
.NET
.NET, System.Security.Cryptography.
public static string GetEncodedSignature(string toSign, string hashKey)
{
byte[] bytes;
byte[] unicodeKey = Convert.FromBase64String(hashKey);
var utf8encodedString = Encoding.UTF8.GetBytes(toSign);
using (var hmac = new HMACSHA256(unicodeKey))
{
bytes = hmac.ComputeHash(utf8encodedString);
}
var signature = Convert.ToBase64String(bytes);
return signature;
}
. Fiddle, HTTP-.
.
MSDN Azure Storage Services