Ejemplo n.º 1
0
 public static string HashSHA256(string password)
 {
     using (System.Security.Cryptography.SHA256Managed crypt = new System.Security.Cryptography.SHA256Managed())
     {
         System.Text.StringBuilder hash = new System.Text.StringBuilder();
         byte[] bytes = crypt.ComputeHash(Encoding.UTF8.GetBytes(password), 0, Encoding.UTF8.GetByteCount(password));
         return(ExtensionsString.BytesToHex(bytes));
     }
 }
Ejemplo n.º 2
0
 public static string HashSHA512File(string path)
 {
     using (FileStream stream = File.OpenRead(path))
     {
         using (SHA512 sha = SHA512.Create())
         {
             byte[] bytes = sha.ComputeHash(stream);
             return(ExtensionsString.BytesToHex(bytes));
         }
     }
 }