ASP.NET Forums
首页 搜索 用户列表 FAQ 注册 登录  
ASP.NET Forums » ASP.NET Forums 2.0 » 转换到ASP.NET Forums 2.0 » DVBBS->ASP.Net Forums转换第一步增加DVBBS的MD5加密方法
  DVBBS->ASP.Net Forums转换第一步增加DVBBS的MD5加密方法
帖子发起人: 流水男孩   发起时间: 2004-12-28 2:59 PM   回复数: 7
« 上一主题 下一主题 »
楼主
  2004-12-28, 2:59 PM
流水男孩 离线,最后访问时间: 2/15/2005 5:57:22 PM 流水男孩



发帖数前50位
男

士兵
等级: 士兵
注册: 2004年12月16日
积分: 17
精华: 0
发贴: 72
DVBBS->ASP.Net Forums转换第一步增加DVBBS的MD5加密方法
 

Components/Enumerations/SecurityEnums.cs中
    public enum UserPasswordFormat {
        ClearText = 0,
        MD5Hash = 1,
        Sha1Hash = 2,
        Encyrpted = 3,
        DVMD5 = 4//增加的 by waterboy
    }
Components/Users.cs

public static string Encrypt(UserPasswordFormat format, string cleanString, string salt)
        {
   Byte[] clearBytes;
   Byte[] hashedBytes;

   System.Text.Encoding encoding = System.Text.Encoding.GetEncoding( AspNetForums.Configuration.ForumConfiguration.GetConfig().PasswordEncodingFormat );

   if( encoding == null ) {
    throw new AspNetForums.Components.ForumException( ForumExceptionType.UnknownError, "An unknown encoding type (" +  AspNetForums.Configuration.ForumConfiguration.GetConfig().PasswordEncodingFormat + ") was specified in the web config file for the property 'passwordEncodingFormat'");
   }

   //clearBytes = encoding.GetBytes( salt.ToLower().Trim() + cleanString.ToLower().Trim() );
   // fix to not force to lowercase, stronger encryption.
   //
   clearBytes = encoding.GetBytes( salt.ToLower().Trim() + cleanString.Trim() );

   switch (format)
   {
    case UserPasswordFormat.ClearText:
     return cleanString;
    case UserPasswordFormat.Sha1Hash:
     // Force the string to lower case and add the salt
     //
//     clearBytes = encoding.GetBytes(salt.Length == 0 ? cleanString : salt + cleanString );
     hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("SHA1")).ComputeHash(clearBytes);

     return BitConverter.ToString(hashedBytes);
     //return Convert.ToBase64String(hashedBytes);
    case UserPasswordFormat.DVMD5://增加的 by waterboy
     return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(cleanString,"md5").ToLower().Substring(8,16);//增加的
    case UserPasswordFormat.MD5Hash:
    case UserPasswordFormat.Encyrpted:
    default:
     // TDD 3/16/2004
     // This algorithm was changed to UTF8 which is not compatible with the existing passwords aleady stored
     // so I'm changing it back to use Unicode encoding like it was originally written with the addition of salt.
     // Force the string to lower case and add the salt
     //    clearBytes = System.Text.Encoding.UTF8.GetBytes(salt != null && salt != String.Empty ? salt.ToLower().Trim() + cleanString.ToLower().Trim() : cleanString.ToLower().Trim() );
     //    hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);

//     clearBytes = encoding.GetBytes(salt == null ? cleanString.ToLower() : salt.ToLower().Trim() + cleanString.ToLower().Trim() );
     hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);

     return BitConverter.ToString(hashedBytes);
     //return Convert.ToBase64String(hashedBytes);                     
   }
        }



只需要注意注释“增加的”

我已经测试通过。


IP 地址: 已登录   来自: 已登录    返回顶部
第 2 楼
  2004-12-28, 10:16 PM
流水男孩 离线,最后访问时间: 2/15/2005 5:57:22 PM 流水男孩



发帖数前50位
男

士兵
等级: 士兵
注册: 2004年12月16日
积分: 17
精华: 0
发贴: 72
Re: DVBBS->ASP.Net Forums转换第一步增加DVBBS的MD5加密方法
 
能不能移到 转换版去呀~
IP 地址: 已登录   来自: 已登录    返回顶部
第 3 楼
  2004-12-28, 10:48 PM
玄天尊 离线,最后访问时间: 9/7/2008 1:14:24 AM 玄天尊



发帖数前50位
男

版主
职务: 版主
排长
等级: 排长
注册: 2004年11月4日
积分: 80
精华: 1
发贴: 84
Re: DVBBS->ASP.Net Forums转换第一步增加DVBBS的MD5加密方法
 
支持支持


IP 地址: 已登录   来自: 已登录    返回顶部
第 4 楼
  2004-12-29, 9:47 AM
清水飘萍 离线,最后访问时间: 12/16/2005 12:21:43 AM 清水飘萍

发帖数前50位

士兵
等级: 士兵
注册: 2004年12月11日
积分: 32
精华: 0
发贴: 64
Re: DVBBS->ASP.Net Forums转换第一步增加DVBBS的MD5加密方法
 
流水男孩
建议完成这个功能呀?
这都是大家所需要的。
IP 地址: 已登录   来自: 已登录    返回顶部
第 5 楼
  2005-1-13, 9:39 AM
koukou1 离线,最后访问时间: 4/21/2005 5:19:48 PM koukou1

无等级

士兵
等级: 士兵
注册: 2005年1月11日
积分: 3
精华: 0
发贴: 2
Re: DVBBS->ASP.Net Forums转换第一步增加DVBBS的MD5加密方法
 
能不能把你改好的WEB程序发上来分享啊

IP 地址: 已登录   来自: 已登录    返回顶部
第 6 楼
  2005-4-12, 10:20 PM
彭鹏 离线,最后访问时间: 4/12/2005 11:11:35 PM 彭鹏



无等级
男

士兵
等级: 士兵
注册: 2005年4月12日
积分: 7
精华: 0
发贴: 7
Re: DVBBS->ASP.Net Forums转换第一步增加DVBBS的MD5加密方法
 
顶!!!!!!!!!!!!!!!
IP 地址: 已登录   来自: 已登录    返回顶部
第 7 楼
  2005-8-25, 9:53 AM
ggg 离线,最后访问时间: 1/31/2007 11:46:07 PM ggg



发帖数前50位

排长
等级: 排长
注册: 2005年2月4日
积分: 113
精华: 0
发贴: 92
Re: DVBBS->ASP.Net Forums转换第一步增加DVBBS的MD5加密方法
附件:
bin.rar(155K, 下载:1567),
 
最新版还应改下面两个文件
web/Languages/zh-CN/Resources.xml
<resource name="MemberSettings_FormatMode_Clear">原始密码</resource>
<resource name="MemberSettings_FormatMode_MD5">MD5 加密</resource>
<resource name="MemberSettings_FormatMode_SHA1">Sha1 加密</resource>
<resource name="MemberSettings_FormatMode_Encrypted">加密</resource>
<resource name="MemberSettings_FormatMode_DVMD5">DVMD5加密</resource>//增加的 by bbs.eyetao.com
Controls/Utility/PasswordFormatDropDownList.cs
this.Items.Add( new ListItem( ResourceManager.GetString("MemberSettings_FormatMode_Clear"), AspNetForums.Enumerations.UserPasswordFormat.ClearText.ToString() ));
this.Items.Add( new ListItem( ResourceManager.GetString("MemberSettings_FormatMode_MD5"), AspNetForums.Enumerations.UserPasswordFormat.MD5Hash.ToString() ));
this.Items.Add( new ListItem( ResourceManager.GetString("MemberSettings_FormatMode_SHA1"), AspNetForums.Enumerations.UserPasswordFormat.Sha1Hash.ToString() ));
this.Items.Add( new ListItem( ResourceManager.GetString("MemberSettings_FormatMode_Encrypted"), AspNetForums.Enumerations.UserPasswordFormat.Encyrpted.ToString() ));
this.Items.Add( new ListItem( ResourceManager.GetString("MemberSettings_FormatMode_DVMD5"), AspNetForums.Enumerations.UserPasswordFormat.DVMD5.ToString() ));//增加的 by bbs.eyetao.com

IP 地址: 已登录   来自: 已登录    返回顶部
第 8 楼
  2006-7-4, 10:16 AM
sos 离线,最后访问时间: 11/4/2006 5:49:55 PM sos

无等级

士兵
等级: 士兵
注册: 2006年5月24日
积分: 7
精华: 0
发贴: 6
Re: DVBBS->ASP.Net Forums转换第一步增加DVBBS的MD5加密方法
 
 ggg wrote:
最新版还应改下面两个文件
web/Languages/zh-CN/Resources.xml
<resource name="MemberSettings_FormatMode_Clear">原始密码</resource>
<resource name="MemberSettings_FormatMode_MD5">MD5 加密</resource>
<resource name="MemberSettings_FormatMode_SHA1">Sha1 加密</resource>
<resource name="MemberSettings_FormatMode_Encrypted">加密</resource>
<resource name="MemberSettings_FormatMode_DVMD5">DVMD5加密</resource>//增加的 by bbs.eyetao.com



XML里 "//"不能加吧, 加了要出错的
IP 地址: 已登录   来自: 已登录    返回顶部
 第 1 页 总共 1 页 [共有 8 条记录]
ASP.NET Forums » ASP.NET Forums 2.0 » 转换到ASP.NET Forums 2.0 » DVBBS->ASP.Net Forums转换第一步增加DVBBS的MD5加密方法

友情链接: hiDotNet官方论坛 | hiDotNet知识库 | 其它友情链接

Asp.Net Forums version: 2.5.2725
(C)Copyright 2004-2007, hiDotNet.com. All Rights Reserved.
意见反馈 | 关于我们

Powered by Community Server :: Forums 中文本地化: hiDotNet.com