在C#中怎么用md5的密码

zfh198601 2009-01-15 12:07:31
在C#中怎么用md5的密码

md5的密码代码是asp的代码.
...全文
139 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zfh198601 2009-01-15
  • 打赏
  • 举报
回复
不是有句:FormsAuthentication.HashPasswordForStoringInConfigFile(this.UserPwd.Text, "MD5")
但是这个是32位的,有没有16位的,也像这样简单的.
舞台中央的我 2009-01-15
  • 打赏
  • 举报
回复
xuexi[Quote=引用 3 楼 qiume 的回复:]
C# codeusing 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>

[/Quote]
zfh198601 2009-01-15
  • 打赏
  • 举报
回复
16位的...

因为我要兼容以前的ASP代码,,,
qiume 2009-01-15
  • 打赏
  • 举报
回复
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;
}
}
}

chjpeng 2009-01-15
  • 打赏
  • 举报
回复
Md5密码是个字符串,16位或32位
应该是Md5的方法吧?不如重新写个C#的,google或百度找段
herty 2009-01-15
  • 打赏
  • 举报
回复
吃饭去回来给你说!
a12321321321312321 2009-01-15
  • 打赏
  • 举报
回复

string MD5(string strSource)
{
UnicodeEncoding uEncode = new UnicodeEncoding();
byte[] bs = uEncode.GetBytes(strSource);
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
return Convert.ToBase64String(md5.ComputeHash(bs));
}

zfh198601 2009-01-15
  • 打赏
  • 举报
回复
FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8, 16);

我自己解决了,但是还是谢谢你们.

111,131

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧