Last active
May 24, 2024 22:55
-
-
Save goors/0ba3b0d2b08b8b22d351b13d3288ade5 to your computer and use it in GitHub Desktop.
This file contains 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
public string HashSecret(string secret) { | |
using var sha256 = SHA256.Create(); | |
// Compute hash of the password | |
var hashBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(secret)); | |
// Convert byte array to a hexadecimal string | |
var builder = new StringBuilder(); | |
foreach (var t in hashBytes) { | |
builder.Append(t.ToString("x2")); | |
} | |
return builder.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test hash:
473287f8298dba7163a897908958f7c0eae733e25d2e027992ea2edc9bed2fa8