Last active
July 23, 2024 15:01
-
-
Save joelverhagen/d8e8571c62d0b2bee3c3630e1ad4858f to your computer and use it in GitHub Desktop.
Revisions
-
joelverhagen revised this gist
Jul 23, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,5 +17,5 @@ private static string GenerateVersionId(Guid extensionId, string version, string byte[] input = Encoding.UTF8.GetBytes(builder.ToString()); byte[] hash = SHA256.HashData(input); // SHA-256 because input is user provided, and because Kusto hash_sha256 exists return Convert.ToHexString(hash).ToLowerInvariant(); // lowercase to be consistent with CDN URL casing (and less yelling) } -
joelverhagen created this gist
Jul 23, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ private static string GenerateVersionId(Guid extensionId, string version, string? targetPlatform) { StringBuilder builder = new(); builder.Append(extensionId.ToString("D")); // use default string format builder.Append('|'); // extension ID cannot contain '|' builder.Append(version.ToLowerInvariant()); // SQL collation is case insensitive if (targetPlatform is not null) { builder.Append('|'); // version cannot contain '|' builder.Append(targetPlatform.ToLowerInvariant()); // SQL collation is case insensitive } // if future non-null fields are added, a '|' should be added for target platform byte[] input = Encoding.UTF8.GetBytes(builder.ToString()); byte[] hash = SHA256.HashData(input); // SHA-256 because input is user provided, and because Kusto hash_sha256 exists return Convert.ToHexString(hash).ToLowerInvariant(); }