posted 1/9/2009 by Vijendra Shakya
Many developers save the password in normal form in Database which is not secure for the user because every one who have the access of the database view your password it is very harmful for the user.To encode the password use the using System.Security.Cryptography namespace;Following is the method to encode the pwd in MD5 format.
using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Collections.Generic;using System.Security.Cryptography;// method to encode passwordpublic string EncodePassword(string userpassword){ Byte[] originalPwdBytes; Byte[] encodedPwdBytes; MD5 md5;//Instantiate MD5CryptoServiceProvider, get bytes for user's original password and encode password in MD5 format. md5 = new MD5CryptoServiceProvider(); originalPwdBytes= ASCIIEncoding.Default.GetBytes(userpassword); encodedPwdBytes= md5.ComputeHash(originalPwdBytes); //Convert encoded user password in 'readable" format. return BitConverter.ToString(encodedPwdBytes);}
Hope it will helpful ...
What kind of email newsletter would you prefer to receive from CodeAsp.Net?18