用户操作
[即时聊天] [发私信] [加为好友]
桂蕾ID:daqingshu
22586次访问,排名5251(-2)好友0人,关注者0
daqingshu的文章
原创 14 篇
翻译 0 篇
转载 23 篇
评论 5 篇
阿呆的公告
还是喜欢那一片幽静 致远的地方 真的好舒服吗? 等到我去的时候 你还是那样美丽吗?
Q俺 Free Counter
Free Counter
最近评论
hero19851205:又是和别人一样的东西
文章分类
收藏
相册
Blogs
存档
软件项目交易
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
订阅到BlogLines
订阅到Yahoo
订阅到GouGou
订阅到飞鸽
订阅到Rojo
订阅到newsgator
订阅到netvibes

原创 用VB2005实现的ASP时代的MD5加密算法收藏

新一篇: visual studio 2005小tip之自动添加文件模版信息  | 旧一篇: TRULY Understanding Dynamic Controls (Part 2)

算法实现很简单,改造已有的vbscript代码就可以了

至于用处,也许可以为以前ASP程序遗留的数据作兼容,性能上面,当然不如.NET framework自带的性能高,不过 优化之后大致测试了一下,对于一个20长度的中文汉字加密需要时间大概在0.02秒左右

代码不好看,只提供类库下载

http://www.cnblogs.com/Files/daqingshu/ASPMD5.rar

空间没有了

使用方法很简单

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.Diagnostics;
using System.Text;

namespace wpDemo
{
    
static class starter
    
{
        
/// <summary>
        
/// The main entry point for the application.
        
/// </summary>

        [STAThread]
        
static void Main()
        
{
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(
false);           
            Generic.Algorithms.ASPMD5 md5 
= new Generic.Algorithms.ASPMD5();
            
string strPassword = "中国中国中国中国中国中国中国中国中国中国";
            Stopwatch horse 
= new Stopwatch();
            horse.Start();
            
string a = md5.MD5(strPassword, 32);
            horse.Stop();
            Console.WriteLine(horse.Elapsed.ToString());
            Console.WriteLine(a);

            MD5CryptoServiceProvider hashmd5;
            hashmd5 
= new MD5CryptoServiceProvider();
            horse.Reset();
            horse.Start();
            
byte[] md5arr = hashmd5.ComputeHash(Encoding.Default.GetBytes(strPassword));
            
string b = BitConverter.ToString(md5arr).Replace("-""").ToLower();
            horse.Stop();
            Console.WriteLine(horse.Elapsed.ToString());            
            Console.WriteLine(b);            

            Console.ReadLine();
        }






        
static char[] hexDigits = {
        
'0''1''2''3''4''5''6''7',
        
'8''9''A''B''C''D''E''F'}
;

        
public static string ToHexString(byte[] bytes)
        
{
            
char[] chars = new char[bytes.Length * 2];
            
for (int i = 0; i < bytes.Length; i++)
            
{
                
int b = bytes[i];
                chars[i 
* 2= hexDigits[b >> 4];
                chars[i 
* 2 + 1= hexDigits[b & 0xF];
            }

            
return new string(chars);
        }

    }

}

发表于 @ 2006年10月17日 21:51:00|评论(loading...)|编辑

新一篇: visual studio 2005小tip之自动添加文件模版信息  | 旧一篇: TRULY Understanding Dynamic Controls (Part 2)

评论:没有评论。

发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © 阿呆