From cce7af99f5e811c4bb04bcde1aea855c88fdd651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20SEVG=C4=B0L?= <58181311+BatuhanSevgil@users.noreply.github.com> Date: Sun, 14 Mar 2021 17:07:49 +0300 Subject: [PATCH 1/2] =?UTF-8?q?Do=C4=9Frulama=20Methodu=20Refactor=20edild?= =?UTF-8?q?i?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Byte doğrulaması for yerine System.Linq Üzerinden sağlandı --- Core/Utilities/Security/Hashing/HashingHelper.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Core/Utilities/Security/Hashing/HashingHelper.cs b/Core/Utilities/Security/Hashing/HashingHelper.cs index 2d86dbf..5e36a09 100644 --- a/Core/Utilities/Security/Hashing/HashingHelper.cs +++ b/Core/Utilities/Security/Hashing/HashingHelper.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Collections.Generic; using System.Text; @@ -20,16 +21,8 @@ public static bool VerifyPasswordHash(string password, byte[] passwordHash, byte using (var hmac = new System.Security.Cryptography.HMACSHA512(passwordSalt)) { var computedHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(password)); - for (int i = 0; i < computedHash.Length; i++) - { - if (computedHash[i]!=passwordHash[i]) - { - return false; - } - } + return computedHash.SequenceEqual(passwordHash) == true ? true : false; } - - return true; } } } From 468391884bfde466c6e2234d15ea04340872f09b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20SEVG=C4=B0L?= <58181311+BatuhanSevgil@users.noreply.github.com> Date: Tue, 19 Oct 2021 12:29:24 +0300 Subject: [PATCH 2/2] Update HashingHelper.cs --- Core/Utilities/Security/Hashing/HashingHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Utilities/Security/Hashing/HashingHelper.cs b/Core/Utilities/Security/Hashing/HashingHelper.cs index 5e36a09..45cb2ea 100644 --- a/Core/Utilities/Security/Hashing/HashingHelper.cs +++ b/Core/Utilities/Security/Hashing/HashingHelper.cs @@ -21,7 +21,7 @@ public static bool VerifyPasswordHash(string password, byte[] passwordHash, byte using (var hmac = new System.Security.Cryptography.HMACSHA512(passwordSalt)) { var computedHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(password)); - return computedHash.SequenceEqual(passwordHash) == true ? true : false; + return computedHash.SequenceEqual(passwordHash); } } }