mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
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:
1 parent
fb5f191b36
commit
4a879f582c
1 file changed
+4
-1
@@ -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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user