The MAC signature found in the HTTP request '…' is not the same as any computed signature

谁说胖子不能爱 提交于 2019-12-01 03:18:39

Authentication for Azure Storage is not simply a matter of providing the access key (that is not very secure). You need to create a signature string that represents the given request, sign the string with the HMAC-SHA256 algorithm (using your storage key to sign), and encode the result in base 64. See https://msdn.microsoft.com/en-us/library/azure/dd179428.aspx for full details, including how to construct the signature string.

Just got this working, here's my code:

string signWithAccountKey(string stringToSign, string accountKey)
{
    var hmacsha = new System.Security.Cryptography.HMACSHA256();
    hmacsha.Key = Convert.FromBase64String(accountKey);
    var signature = hmacsha.ComputeHash(Encoding.UTF8.GetBytes(stringToSign));
    return Convert.ToBase64String(signature);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!