Hash the full UTF-8 byte length in HashStrings (#1355)

HashStrings passed str.Length (a char count) as the byte count to
MD5.TransformBlock, so for any non-ASCII string only a truncated prefix
of the UTF-8 bytes was hashed. Capture the byte array and use its Length.
This commit is contained in:
HetCreep authored and GitHub committed 2026-06-21 12:20:41 +02:00
1 parent fb5f191b36
commit 4a879f582c
1 file changed
+4 -1
+4 -1
View File
@@ -331,7 +331,10 @@ public static class Utility
using var md5 = MD5.Create();
foreach (var str in strings)
md5.TransformBlock(Encoding.UTF8.GetBytes(str), 0, str.Length, null, 0);
{
var bytes = Encoding.UTF8.GetBytes(str);
md5.TransformBlock(bytes, 0, bytes.Length, null, 0);
}
md5.TransformFinalBlock(new byte[0], 0, 0);