From 680aa17c551c1494bad584bfefe6c49ea0950d49 Mon Sep 17 00:00:00 2001 From: Blank Date: Wed, 29 Jul 2026 21:49:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(hash):=20=E6=8A=91=E5=88=B6=20Md5Helper=20?= =?UTF-8?q?=E7=9A=84=20Sonar=20S4790=20=E5=BC=B1=E5=93=88=E5=B8=8C?= =?UTF-8?q?=E6=BC=8F=E6=B4=9E=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Linear: GFX-199 --- GameFrameX.Foundation.Hash/Md5Helper.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GameFrameX.Foundation.Hash/Md5Helper.cs b/GameFrameX.Foundation.Hash/Md5Helper.cs index a6e8c36..fb2290a 100644 --- a/GameFrameX.Foundation.Hash/Md5Helper.cs +++ b/GameFrameX.Foundation.Hash/Md5Helper.cs @@ -31,6 +31,7 @@ // Official Documentation: https://gameframex.doc.alianblank.com/ // ========================================================================================== +using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; using System.Text; @@ -62,6 +63,7 @@ public static class Md5Helper /// 是否返回大写形式的哈希值,默认为false返回小写 / Whether to return uppercase hash, defaults to false for lowercase /// 32个字符的十六进制字符串形式的哈希值 / A 32-character hexadecimal string hash value /// 为 null 时抛出 / Thrown when is null + [SuppressMessage("Sonar Code Smell", "S4790:Use a stronger hashing algorithm", Justification = "MD5 is intentionally used here for non-cryptographic checksum / fingerprint / cache-key scenarios; for security-sensitive use cases call Sha256Helper instead.")] public static string Hash(string input, bool isUpper = false) { ArgumentNullException.ThrowIfNull(input, nameof(input)); @@ -104,6 +106,7 @@ public static string HashWithSalt(string input, string salt, bool isUpper = fals /// 是否返回大写形式的哈希值,默认为false返回小写 / Whether to return uppercase hash, defaults to false for lowercase /// 32个字符的十六进制字符串形式的哈希值 / A 32-character hexadecimal string hash value /// 为 null 时抛出 / Thrown when or is null + [SuppressMessage("Sonar Code Smell", "S4790:Use a stronger hashing algorithm", Justification = "MD5 is intentionally used here for non-cryptographic checksum / fingerprint / cache-key scenarios; for security-sensitive use cases call Sha256Helper instead.")] public static string HashWithSalt(string input, byte[] salt, bool isUpper = false) { ArgumentNullException.ThrowIfNull(input, nameof(input)); @@ -130,6 +133,7 @@ public static string HashWithSalt(string input, byte[] salt, bool isUpper = fals /// 是否返回大写形式的哈希值,默认为false返回小写 / Whether to return uppercase hash, defaults to false for lowercase /// 32个字符的十六进制字符串形式的哈希值 / A 32-character hexadecimal string hash value /// 为 null 时抛出 / Thrown when is null + [SuppressMessage("Sonar Code Smell", "S4790:Use a stronger hashing algorithm", Justification = "MD5 is intentionally used here for non-cryptographic checksum / fingerprint / cache-key scenarios; for security-sensitive use cases call Sha256Helper instead.")] public static string Hash(byte[] input, bool isUpper = false) { ArgumentNullException.ThrowIfNull(input, nameof(input)); @@ -149,6 +153,7 @@ public static string Hash(byte[] input, bool isUpper = false) /// 要计算哈希值的流,不能为null / The stream to compute the hash for, cannot be null /// 32个字符的十六进制字符串形式的哈希值 / A 32-character hexadecimal string hash value /// 为 null 时抛出 / Thrown when is null + [SuppressMessage("Sonar Code Smell", "S4790:Use a stronger hashing algorithm", Justification = "MD5 is intentionally used here for non-cryptographic checksum / fingerprint / cache-key scenarios; for security-sensitive use cases call Sha256Helper instead.")] public static string Hash(Stream input) { ArgumentNullException.ThrowIfNull(input, nameof(input)); @@ -163,6 +168,7 @@ public static string Hash(Stream input) /// 要计算哈希值的流 / The stream to compute the hash for /// 用于取消异步操作的令牌 / Token used to cancel the asynchronous operation /// 小写十六进制字符串形式的哈希值 / The lowercase hexadecimal hash value + [SuppressMessage("Sonar Code Smell", "S4790:Use a stronger hashing algorithm", Justification = "MD5 is intentionally used here for non-cryptographic checksum / fingerprint / cache-key scenarios; for security-sensitive use cases call Sha256Helper instead.")] public static async Task HashAsync(Stream input, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(input, nameof(input));