From 274d5e1c10fdc394e72b803aaa113e264e2516ae Mon Sep 17 00:00:00 2001 From: Joyless <65855333+Joy-less@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:22:48 +0100 Subject: [PATCH] Replace Mutex name hashing with URI escaping --- LiteDB/Client/Shared/SharedEngine.cs | 2 +- LiteDB/Utils/Extensions/StringExtensions.cs | 18 ------------------ 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/LiteDB/Client/Shared/SharedEngine.cs b/LiteDB/Client/Shared/SharedEngine.cs index c25e7d591..27ac9d5f6 100644 --- a/LiteDB/Client/Shared/SharedEngine.cs +++ b/LiteDB/Client/Shared/SharedEngine.cs @@ -21,7 +21,7 @@ public SharedEngine(EngineSettings settings) { _settings = settings; - var name = Path.GetFullPath(settings.Filename).ToLower().Sha1(); + string name = Uri.EscapeDataString(Path.GetFullPath(settings.Filename).ToLowerInvariant()); try { diff --git a/LiteDB/Utils/Extensions/StringExtensions.cs b/LiteDB/Utils/Extensions/StringExtensions.cs index 00ed9b54c..c34afebf8 100644 --- a/LiteDB/Utils/Extensions/StringExtensions.cs +++ b/LiteDB/Utils/Extensions/StringExtensions.cs @@ -37,24 +37,6 @@ public static bool IsWord(this string str) return true; } - public static string Sha1(this string value) - { - var data = Encoding.UTF8.GetBytes(value); - - using (var sha = SHA1.Create()) - { - var hashData = sha.ComputeHash(data); - var hash = new StringBuilder(); - - foreach (var b in hashData) - { - hash.Append(b.ToString("X2")); - } - - return hash.ToString(); - } - } - /// /// Implement SqlLike in C# string - based on /// https://stackoverflow.com/a/8583383/3286260