Skip to content
Prev Previous commit
Next Next commit
Dispose SHA512 instance
  • Loading branch information
TalAloni authored Feb 20, 2021
commit a86258b37ef7cd33e8783070d2d5406530ea0608
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Diagnostics;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;

namespace System.Xml.Serialization
{
Expand Down Expand Up @@ -93,8 +94,11 @@ internal static string GetTempAssemblyName(AssemblyName parent, string? ns)
private static uint GetPersistentHashCode(string value)
{
byte[] valueBytes = System.Text.Encoding.UTF8.GetBytes(value);
byte[] hash = System.Security.Cryptography.SHA512.Create().ComputeHash(valueBytes);
return (uint)(hash[0] << 24 | hash[1] << 16 | hash[2] << 8 | hash[3]);
using (SHA512 sha512 = SHA512.Create())
{
byte[] hash = sha512.ComputeHash(valueBytes);
return (uint)(hash[0] << 24 | hash[1] << 16 | hash[2] << 8 | hash[3]);
}
}
}
}