public static  string Md5Hex(string str)
        {          
            string dest = "";
            //实例化一个md5对像
            MD5 md5 = MD5.Create();
            // 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择 
            byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
            // 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
            for (int i = 0; i < s.Length; i++)
            {
                // 将得到的字符串使用十六进制类型格式。格式后的字符是大写的字母
                
                if (s[i] < 16) 

dest = dest + "0" + s[i].ToString("X"); 

else 

dest = dest + s[i].ToString("X"); 
}             }
            return dest;
        }
小要求:http://www.xxx.com/index.aspx?str=xxxx就自动调用这个函数 然后write返回的结果 我这没有vs,急用这个过程。编译后麻烦发送到[email protected] 谢谢 急用。

解决方案 »

  1.   

    什么意思,编译成asp.net?
      

  2.   

    <%@ WebHandler Language="C#" Class="Handler" %>using System;
    using System.Web;public class Handler : IHttpHandler {
        
        public void ProcessRequest (HttpContext context) {
            String str=context.Request.QueryString["str"].ToString();    
                string dest = "";
                //实例化一个md5对像
                MD5 md5 = MD5.Create();
                // 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择 
                byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
                // 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
                for (int i = 0; i < s.Length; i++)
                {
                    // 将得到的字符串使用十六进制类型格式。格式后的字符是大写的字母                if (s[i] < 16)
                    {
                        dest = dest + "0" + s[i].ToString("X");
                    }
                    else
                    {
                        dest = dest + s[i].ToString("X");
                    }
                }
            context.Response.Write("Hello World");
        }    public bool IsReusable
        {
            get
            {
                return false;
            }
        }}
      

  3.   


    我这里没有.net啊,能不能帮我编译
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Security.Cryptography;
    using System.Web;
      

  4.   

    没 .net 给你编译成 dll 了也没用
      

  5.   

    编译成一个asp.net 我放到空间里用的
      

  6.   

    编译成一个asp.net 我放到空间里用的?我想应该有好多人不明白
      

  7.   

    直接在页面里使用
    <%      
    str-Request.QueryString["str"]==null?"":Request.QueryString["str"].ToString();
     string dest = ""; 
       MD5 md5 = MD5.Create(); 
                byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(str)); 
                for (int i = 0; i < s.Length; i++) 
                { 
                   if (s[i] < 16) 
                   { 
                     dest = dest + "0" + s[i].ToString("X"); 
                   } 
                   else 
                   { 
                    dest = dest + s[i].ToString("X"); 
                   }  
                } 
    Reponse.Write(dest);
    %>
      

  8.   

    已发邮箱
    using System.Text;
    using System.Security.Cryptography;namespace WebApplication1
    {
        public class Class1
        {
            public static string Md5Hex(string str)
            {
                string dest = "";
                //实例化一个md5对像 
                MD5 md5 = MD5.Create();
                // 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择  
                byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
                // 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得 
                for (int i = 0; i < s.Length; i++)
                {
                    // 将得到的字符串使用十六进制类型格式。格式后的字符是大写的字母                 if (s[i] < 16)
                    {
                        dest = dest + "0" + s[i].ToString("X");
                    }
                    else
                    {
                        dest = dest + s[i].ToString("X");
                    }            }
                return dest;
            }     }
    }
      

  9.   

    服务器能自动编译吧?上传上去不行?能上网,自己下载framework,用csc.exe命令自己编译吧,搞不懂你要怎样使用的
      

  10.   


    建一个类库,把这段代码放进去,编译成DLL
      

  11.   

    晕。你没有运行环境,编译了你哪能运行?.net都需要运行环境的。
      

  12.   

    单独编译的话,也需要csc命令来编译,但是你没安装.net环境就没辙了!