Mega Code Archive

 
Categories / C# / Security
 

Hash Password

// Copyright (c) 2010 // by http://openlightgroup.net/ using System; using System.Data; using System.Linq; using System.Web; using System.Xml.Linq; using System.Net.Mail; using System.Text; using System.Collections.Generic; using System.IO; using System.Web.Security; namespace SilverlightDebateForum {     public class Utility     {         #region HashPassword         public static string HashPassword(int UserID, string Password)         {             // Note this password is 'salted' with the username when it is passed             // to this method, so a basic dictionary attack would not work             string HashedPassword = "";             string UserPasswordAttempt = String.Format("{0}{1}", UserID.ToString(), Password);             HashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(UserPasswordAttempt,                 System.Web.Configuration.FormsAuthPasswordFormat.MD5.ToString());             return HashedPassword;         }         #endregion     } }