ASP.NET基础教程-实现MD5和SHA1口令加密
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://chenxing.blog.51cto.com/240526/44981 |
利用FormsAuthentication 类的HashPasswordForStoringInConfigFile 方法实现用户登录口令加密
1、创建password类 using System.Web.Security;引用加密类所在的命明空间 下段代码为加密码过程 public class jmpassword { public string EncryptPassword(string PasswordString,string PasswordFormat ) { string EncryptPassword=""; if (PasswordFormat=="SHA1") { EncryptPassword=FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordString ,"SHA1"); return EncryptPassword; } else if (PasswordFormat=="MD5") { EncryptPassword=FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordString ,"MD5"); return EncryptPassword; } else { EncryptPassword=""; return EncryptPassword; } } } 2、在表单中引用类,并将密码框输入的值进行加密 jmpassword Password=new jmpassword(); string password=Password.EncryptPassword(txtpassword.Text.ToString(),"SHA1")+Password.EncryptPassword(txtpassword.Text.ToString(),"MD5"); |


晨星
博客统计信息
热门文章
最新评论
友情链接

