Created
August 18, 2020 14:18
-
-
Save GergKllai1/546b7840d0b4a7d10a3cd964d2630bb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static string CreateAuthHeader() | |
{ | |
var dateToSign = DateTime.UtcNow.ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", new CultureInfo("en-US")); | |
var stringToSign = $"{dateToSign}\n/{STORAGE_ACCOUNT_NAME}/{TABLE_NAME}"; | |
string signature; | |
using (var hmacSha256 = new HMACSHA256(Convert.FromBase64String(STORAGE_ACCOUNT_KEY))) | |
{ | |
var dataToHmac = Encoding.UTF8.GetBytes(stringToSign); | |
signature = Convert.ToBase64String(hmacSha256.ComputeHash(dataToHmac)); | |
} | |
var authorizationHeader = $"SharedKeyLite {STORAGE_ACCOUNT_NAME}:{signature}"; | |
return authorizationHeader; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment