enhance: get email hash code opimization (#1137)

(cherry picked from commit 839b92a284d6b103894f6a8a39e5ce1f99bb12fa)
This commit is contained in:
qiufengshe 2025-03-31 09:21:38 +08:00 committed by leo
parent 9ee3a00fba
commit 07d99f5fd2
No known key found for this signature in database

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
@ -196,8 +196,8 @@ namespace SourceGit.Models
private string GetEmailHash(string email) private string GetEmailHash(string email)
{ {
var lowered = email.ToLower(CultureInfo.CurrentCulture).Trim(); var lowered = email.ToLower(CultureInfo.CurrentCulture).Trim();
var hash = MD5.Create().ComputeHash(Encoding.Default.GetBytes(lowered)); var hash = MD5.HashData(Encoding.Default.GetBytes(lowered).AsSpan());
var builder = new StringBuilder(); var builder = new StringBuilder(hash.Length * 2);
foreach (var c in hash) foreach (var c in hash)
builder.Append(c.ToString("x2")); builder.Append(c.ToString("x2"));
return builder.ToString(); return builder.ToString();