Skip to content

Commit dc08b0f

Browse files
committed
feat!: switch to hex format instead of base64
1 parent 45b6307 commit dc08b0f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

AspNet.MVC5.AssetVersioning.Tests/ExtensionsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void ComputeHash_Returns_Sha256_Hash_of_File_Contents()
3535
{
3636
var hash = AssetVersionCache.ComputeHash("test.txt");
3737

38-
Assert.AreEqual("5b9VrKRrgLl2zwVdUOwhwihZ2cwlYdjQTqgEVV+G624=", hash);
38+
Assert.AreEqual("e5bf55aca46b80b976cf055d50ec21c22859d9cc2561d8d04ea804555f86eb6e", hash);
3939
}
4040

4141
[TestMethod]
@@ -48,7 +48,7 @@ public void GetOrAddCachedVersion_Caches_File_Hash()
4848

4949
Assert.AreEqual(1, cache.Count);
5050
Assert.AreEqual(1, assetCache.Count);
51-
Assert.AreEqual("5b9VrKRrgLl2zwVdUOwhwihZ2cwlYdjQTqgEVV+G624=", assetCache["test.txt"]);
51+
Assert.AreEqual("e5bf55aca46b80b976cf055d50ec21c22859d9cc2561d8d04ea804555f86eb6e", assetCache["test.txt"]);
5252
Assert.AreEqual(hash, assetCache["test.txt"]);
5353

5454
var cachedHash = AssetVersionCache.GetOrAddCachedVersion("test.txt", cache);

src/AssetVersionCache.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using System.Linq;
66
using System.Security.Cryptography;
7+
using System.Security.Policy;
78
using System.Text;
89
using System.Threading.Tasks;
910
using System.Web;
@@ -34,7 +35,8 @@ public static string ComputeHash(string filePath)
3435
{
3536
using (var sha256 = SHA256.Create())
3637
{
37-
return Convert.ToBase64String(sha256.ComputeHash(stream));
38+
return BitConverter.ToString(sha256.ComputeHash(stream))
39+
.Replace("-", "").ToLower();
3840
}
3941
}
4042
}

0 commit comments

Comments
 (0)