Skip to content

Instantly share code, notes, and snippets.

@nmackenzie
Last active December 22, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nmackenzie/6482463 to your computer and use it in GitHub Desktop.
Save nmackenzie/6482463 to your computer and use it in GitHub Desktop.
public static String CreateAuthorizationHeader(String canonicalizedString) {
String signature = String.Empty;
using (HMACSHA256 hmacSha256 = new HMACSHA256( Convert.FromBase64String(storageAccountKey) )) {
Byte[] dataToHmac = System.Text.Encoding.UTF8.GetBytes(canonicalizedString);
signature = Convert.ToBase64String(hmacSha256.ComputeHash(dataToHmac));
}
String authorizationHeader = String.Format(
CultureInfo.InvariantCulture,
"{0} {1}:{2}",
AzureStorageConstants.SharedKeyAuthorizationScheme,
AzureStorageConstants.Account,
signature
);
return authorizationHeader;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment