fork download
  1. using System;
  2. using System.Security.Cryptography;
  3. using System.Text;
  4. using System.Threading.Tasks;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. Console.WriteLine(CalculateHash("admin", "admin"));
  11. Console.WriteLine(CalculateHash("admin", "admin"));
  12. }
  13.  
  14. private static string CalculateHash(string clearTextPassword, string salt)
  15. {
  16. // Convert the salted password to a byte array
  17. var saltedHashBytes = Encoding.UTF8.GetBytes(clearTextPassword + salt);
  18. // Use the hash algorithm to calculate the hash
  19. HashAlgorithm algorithm = new SHA256Managed();
  20. var hash = algorithm.ComputeHash(saltedHashBytes);
  21. // Return the hash as a base64 encoded string to be compared to the stored password
  22. return Convert.ToBase64String(hash);
  23. }
  24. }
Success #stdin #stdout 0.03s 26556KB
stdin
Standard input is empty
stdout
2CSU8F1pF7oC96qilonMtES7c/IDgIdssF0fN1N7eJI=
2CSU8F1pF7oC96qilonMtES7c/IDgIdssF0fN1N7eJI=