From 6f22527ad74a389b1bbe3939e9a4f3157b5e8221 Mon Sep 17 00:00:00 2001 From: Andrii Chebukin Date: Fri, 18 Sep 2026 15:22:20 +0200 Subject: [PATCH] Refactored MD5Hash to use `String.Concat` and a single `MD5` instance per call. --- src/FSharp.Data.GraphQL.Client/Extensions.fs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/FSharp.Data.GraphQL.Client/Extensions.fs b/src/FSharp.Data.GraphQL.Client/Extensions.fs index 794118f6..e622c8ce 100644 --- a/src/FSharp.Data.GraphQL.Client/Extensions.fs +++ b/src/FSharp.Data.GraphQL.Client/Extensions.fs @@ -11,6 +11,7 @@ open System.Security.Cryptography /// Extensions for types used by the GraphQL client library. [] module internal Extensions = + type String with /// Returns the input string with the first character in upper case. member this.FirstCharUpper() = @@ -20,11 +21,13 @@ module internal Extensions = member this.FirstCharLower() = this.Substring(0, 1).ToLowerInvariant() + this.Substring(1) - member this.MD5Hash() = - Encoding.UTF8.GetBytes(this) - |> MD5.Create().ComputeHash + /// Returns a lowercase hex MD5 hash of the UTF-8 bytes of this string. + member this.MD5Hash () = + use md5 = MD5.Create() + + md5.ComputeHash (Encoding.UTF8.GetBytes this) |> Seq.map _.ToString("x2") - |> Seq.reduce (+) + |> String.Concat /// Basic operations on lists. module internal List =