CSharp examples for Security:Hash
Calculate the Hash Code of a Password
using System;//from ww w.j a v a 2 s .c o m using System.Text; using System.Security.Cryptography; class MainClass { public static void Main(string[] args) { HashAlgorithm hashAlg = null; if (args[0].CompareTo("SHAManaged1") == 0) { hashAlg = new SHA1Managed(); } else { hashAlg = HashAlgorithm.Create(args[0]); } using (hashAlg) { byte[] pwordData = Encoding.Default.GetBytes(args[1]); byte[] hash = hashAlg.ComputeHash(pwordData); Console.WriteLine(BitConverter.ToString(hash)); } } }