Created
November 3, 2022 14:38
-
-
Save farukcan/f1af332cf951f5a2174236f129aaaf30 to your computer and use it in GitHub Desktop.
C# SHA256 Helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Security.Cryptography; | |
| using System.Text; | |
| namespace FarukCan.Helpers | |
| { | |
| public static class Sha256Helper | |
| { | |
| public static string GetSha256Hash(this string input,string salt="") | |
| { | |
| using (SHA256 sha256Hash = SHA256.Create()) | |
| { | |
| byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input+salt)); | |
| StringBuilder builder = new StringBuilder(); | |
| for (int i = 0; i < bytes.Length; i++) | |
| { | |
| builder.Append(bytes[i].ToString("x2")); | |
| } | |
| return builder.ToString(); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment