There is a relatively obscure static method in the System.Web.Security namespace appropriately entitled “HashPasswordForStoringInConfigFile”. You can use this method anywhere, it does not need to be a Web Application. All you need is a reference to the System.Web assembly.
Here is some sample code to use this:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.Security; namespace HashPassword { class Program { static void Main(string[] args) { Console.WriteLine("Enter a password to hash:"); string password= Console.ReadLine(); string hashed= System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1"); Console.WriteLine("HASHED: " +hashed); Console.WriteLine("Any key to quit."); Console.ReadLine(); } } }
















