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;
}
}
}
Ïà¹ØÎĵµ£º
ASP.NETÒ³ÃæÓëIISµ×²ã½»»¥ºÍ¹¤×÷ÔÀíÏê½â
µÚÒ»»Ø£º
ÒýÑÔ
ÎÒ²éÔĹý²»ÉÙAsp.NetµÄÊé¼®£¬·¢ÏÖ´ó¶àÊý×÷Õß¶¼ÊÇÕ¾ÔÚÒ»¸ö±È½Ï¸ßµÄ²ã´ÎÉϽ²½âAsp.Net¡£ËûÃÇÄÍÐÄ¡¢Ï¸ÖµظæËßÄãÈçºÎÒ»²½²½ÍϷſؼþ¡¢ÉèÖÿؼþÊôÐÔ¡¢±àдCodeBehind´úÂ룬ÒÔʵÏÖij¸öÌØ¶¨µÄ¹¦ÄÜ¡£
ÕâÖÖ×ö·¨£¬Êµ¼ÊÉÏÊǻشðÁË“ÈçºÎÈ¥×ö”µÄÎÊÌ⣬ȴà ......
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 ......
Ò»).´´½¨²¿ÊðÏîÄ¿
1. ÔÚ“Îļþ”²Ëµ¥ÉÏÖ¸Ïò“Ìí¼ÓÏîÄ¿”£¬È»ºóÑ¡Ôñ“н¨ÏîÄ¿”¡£
2. ÔÚ“Ìí¼ÓÐÂÏîÄ¿”¶Ô»°¿òÖУ¬Ñ¡Ôñ“ÏîÄ¿ÀàÐÍ”´°¸ñÖеē°²×°ºÍ²¿ÊðÏîÄ¿”£¬È»ºóÑ¡Ôñ“Ä£°å”´°¸ñ ......
ÎÒÓÐÒ»¸ölogin.aspxµÄÒ³Ãæ,¼ÙÈçµÇ¼³É¹¦ºó¾Í»á×Ô¶¯Ìø×ªµ½index.htmlµÄ¿ò¼Ü.
index.htmlÓÐÈý¸öÒ³Ãæ,top.aspx,left.aspx,main.aspx,È»ºóleft.aspxÀïÃæÏÔʾÓû§ÐÅÏ¢
¼ÙÈçÔÚleft.aspxÀïûÓÐSessionµÄ»°,»á·µ»Ølogin.aspxÒ³Ãæ,¶ø²»ÏÔʾindex.htmlÒ³ÃæÀïµÄÈκÎÒ»Ò³.
ÎÒÏÖÔÚµÄÇé¿öÊÇûÓÐSessionµÄʱºò»¹ÊÇÔÚi ......