C# asp.netÈçºÎʹÓÃMD5¼ÓÃÜ£¬½âÃÜ
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;namespace md5
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(UserMd5("8"));
Console.WriteLine(GetMd5Str("8"));
}
/**//// <summary>
/// MD5 16λ¼ÓÃÜ
/// </summary>
/// <param name="ConvertString"></param>
/// <returns></returns>
public static string GetMd5Str(string ConvertString)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(ConvertString)), 4, 8);
t2 = t2.Replace("-", "");
return t2;
}/**//// <summary>
/// MD5¡¡32λ¼ÓÃÜ
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
static string UserMd5(string str)
{
string cl = str;
string pwd = "";
MD5 md5 = MD5.Create();//ʵÀý»¯Ò»¸ömd5¶ÔÏñ
// ¼ÓÃܺóÊÇÒ»¸ö×Ö½ÚÀàÐ͵ÄÊý×飬ÕâÀïҪעÒâ±àÂëUTF8/UnicodeµÈµÄÑ¡Ôñ¡¡
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(cl));
// ͨ¹ýʹÓÃÑ»·£¬½«×Ö½ÚÀàÐ͵ÄÊý×éת»»Îª×Ö·û´®£¬´Ë×Ö·û´®Êdz£¹æ×Ö·û¸ñʽ»¯ËùµÃ
for (int i = 0; i < s.Length; i++)
{
// ½«µÃµ½µÄ×Ö·û´®Ê¹ÓÃÊ®Áù½øÖÆÀàÐ͸ñʽ¡£¸ñʽºóµÄ×Ö·ûÊÇСдµÄ×Öĸ£¬Èç¹ûʹÓôóд£¨X£©Ôò¸ñʽºóµÄ×Ö·ûÊÇ´óд×Ö·û pwd = pwd + s[i].ToString("X");}
return pwd;
}
}
}
Ïà¹ØÎĵµ£º
java ´úÂë
package util;
import java.io.UnsupportedEncodingException;
import dao.socket.OperType;
public class Encrpt {
private String key;
public Encrpt() {
this("sitow");
}
public Encrpt(String key) {
this.key = key;
}
private ......
ÔÚ°²È«ÐÔÒªÇó²»ÊǺܸߵÄASP.Net³ÌÐòÖУ¬»ùÓÚFormsµÄÉí·ÝÑéÖ¤ÊǾ³£Ê¹ÓõÄÒ»ÖÖ·½Ê½£¬¶øÈç¹ûÐèÒª¶ÔWebService½øÐÐÉí·ÝÑéÖ¤£¬×î³£ÓõĿÉÄÜÊÇ»ùÓÚSoap ±êÍ·µÄ×Ô¶¨ÒåÉí·ÝÑéÖ¤·½Ê½¡£Èç¹û¶ÔÁ½Õß×öһϱȽϵϰ£¬ÏÔÈ»£¬»ùÓÚFormsµÄÑéÖ¤·½Ê½¸ü¼Ó·½±ãÒ×Óã¬ÄÜ·ñ½«FormsÑéÖ¤·½Ê½Ó¦Óõ½WebServiceÖÐÈ¥ÄØ£¿
´ÓÀíÂÛÉ ......
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ͼƬ»¬¶¯.aspx.cs" Inherits="ASP.net.ͼƬ»¬¶¯" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  ......
¿ì½Ý¼ü ¹¦ÄÜ
CTRL + SHIFT + BÉú³É½â¾ö·½°¸
CTRL + F7 Éú³É±àÒë
CTRL + O ´ò¿ªÎļþ
CTRL + SHIFT + O´ò¿ªÏîÄ¿
CTRL + SHIFT + CÏÔʾÀàÊÓͼ´°¿Ú
F4 ÏÔʾÊôÐÔ´°¿Ú
SHIFT + F4ÏÔʾÏîÄ¿ÊôÐÔ´°¿Ú
CTRL + SHIFT + EÏÔʾ×ÊÔ´ÊÓͼ
F12 תµ½¶¨Òå
CTRL + F12תµ½ÉùÃ÷
CTRL + ALT + J¶ÔÏóä¯ÀÀ
CTRL + ALT + F1 ......