• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
内蒙古峰回路转armyfeng
博客园    首页    新随笔    联系   管理    订阅  订阅

c#利用Security加密解密口令

先需要using System.Web.Security;

        MD5加密口令#region MD5加密口令
        
public static string encrypt(string spass)
        
{
            
if (spass.Length > 0)
            
{
                
string encryptpass = FormsAuthentication.HashPasswordForStoringInConfigFile(spass, "MD5");
                
return encryptpass;
            }

            
else {
                
return "96E79218965EB72C92A549DD5A330112";//默认密码设为空
            }

        }

        
#endregion

        
可选择性加密口令,MD5Hash16,MD5Hash32,Sha1Hash#region 可选择性加密口令,MD5Hash16,MD5Hash32,Sha1Hash
        
public static string UserPassFormat(string sPass,string encrypt)
        
{
            
if (sPass.Length > 0)
            
{
                
string encryptpass = FormsAuthentication.HashPasswordForStoringInConfigFile(sPass, encrypt);
                
return encryptpass;
            }

            
else
            
{
                
return "";//默认密码设为空
            }


        }

        
#endregion
posted @ 2006-09-23 17:25  老冯  阅读(662)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3