hell8088的专栏
登录
注册
全站
当前博客
空间
博客
好友
相册
留言
.net下的MD5加密应用
收藏
C#用法
/**/
///
<param name="sDataIn">
需要加密的字符串
</param>
///
<param name="move">
偏移量
</param>
///
<returns>
sDataIn加密后的字符串
</returns>
public
string
GetMD5(
string
sDataIn,
string
move)
...
{
System.Security.Cryptography.MD5CryptoServiceProvider md5
=
new
System.Security.Cryptography.MD5CryptoServiceProvider();
byte
[] bytValue, bytHash;
bytValue
=
System.Text.Encoding.UTF8.GetBytes(move
+
sDataIn);
bytHash
=
md5.ComputeHash(bytValue);
md5.Clear();
string
sTemp
=
""
;
for
(
int
i
=
0
; i
<
bytHash.Length; i
++
)
...
{
sTemp
+=
bytHash[i].ToString(
"
x
"
).PadLeft(
2
,
'
0
'
);
}
return
sTemp;
}
textBox1.Text
=
this
.GetMD5(
"
123456
"
,
""
);
结果: e10adc3949ba59abbe56e057f20f883e
另类应用
MD5另类用法
public
class
Md5Convert
...
{
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;
}
}
textBox1.Text
=
Md5Convert.GetMd5Str(
"
123456
"
);
结果:
49
-
BA
-
59
-
AB
-
BE
-
56
-
E0
-
57
发表于 @
2008年01月18日 09:42:00
|
评论(
loading...
)
新一篇: 简单的加密设计
|
旧一篇: 文件下载的制作
用户操作
[即时聊天]
[发私信]
[加为好友]
hell8088
订阅我的博客
文章分类
javascript知识点
JAVA基础知识点
oracle知识点
VS.NET技术开发
其他
网站开发功能点总结
收藏
存档
2008年12月(1)
2008年11月(1)
2008年09月(1)
2008年07月(1)
2008年06月(4)
2008年05月(2)
2008年04月(1)
2008年03月(2)
2008年02月(2)
2008年01月(8)
2007年12月(5)
2007年11月(7)
软件项目交易