[100]C#如何调用javaBean的东东! 升级前系统使用java中的MessageDigest.getInstance("MD5")对密码加密保证到数据库,兄弟们,我如果用C#取代这段验证??能不能直接调用这个.class?。。还是C#中有替代算法? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public string md5(string str,int code) { if(code==16) //16位MD5加密(取32位加密的9~25字符) { return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower().Substring(8,16) ; } else//32位加密 { return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower(); } } //csprivate string TestHashMD5(string TextToHash){ byte[] bytValue; byte[] bytHash; MD5CryptoServiceProvider MD5; MD5 = new MD5CryptoServiceProvider(); bytValue = System.Text.Encoding.UTF8.GetBytes(TextToHash); bytHash = MD5.ComputeHash(bytValue); MD5.Clear(); return Convert.ToBase64String(bytHash);} 感谢。。eglic(圪圪)可能你的第一种算法是通不过地!。。第二种详细看一下! pwd = "fsfsdf32423423324xxxxx"; //密文 String ss2 = pwd.substring(0, 16); //取密码原文前16位 String ss3 = pwd.substring(16, pwd.length()); // 所有剩下地字符串 String s1 = ss3; String s2 = ss2; BASE64Decoder base64decoder = new BASE64Decoder(); byte abyte0[] = base64decoder.decodeBuffer(s2); // 后半字符反编码 MessageDigest messagedigest = MessageDigest.getInstance( "MD5"); messagedigest.update(abyte0); messagedigest.update(password.getBytes("UTF8")); //用户提供的密码 byte abyte1[] = messagedigest.digest(); // 用户输入密码MD5加密 // 后半段代码处理 BASE64Encoder base64encoder = new BASE64Encoder(); String s3 = base64encoder.encode(abyte1); byte abyte2[] = s1.getBytes(); // 前16位 byte abyte3[] = s3.getBytes(); // if (!Arrays.equals(abyte3, abyte2)) { isauthenticated = false; logger.info("认证错误!!"); } else { isauthenticated = true; logger.info("认证正确!!"); }有那位师兄用翻译成C# 求高手们搭救,编写一个控制台应用台程序,来检验装箱和拆箱! 急求C#控制word的源码或例子 下拉框里有很多可选择,为了方便想把已经选择的值隐藏,不再显示在下拉框里,能实现吗? dataset的简单问题 GDI+问题,我想从一个Bitmap文件中复制一个指定区域到一个新的Bitmap空白实例中,请各位大侠指点一二。 通信端口问题(不知道这个问法对否) 文件和字符串 C# 后台如何写正则表达式 关于一个sql语句的写法??在线急急!!!! c#异常 集合已修改;可能无法执行枚举操作 求助。SQL2000不能安装。 如何将xml文件中的记录更新到sqlserver中
{
if(code==16) //16位MD5加密(取32位加密的9~25字符)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower().Substring(8,16) ;
}
else//32位加密
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower();
}
}
private string TestHashMD5(string TextToHash)
{
byte[] bytValue;
byte[] bytHash;
MD5CryptoServiceProvider MD5; MD5 = new MD5CryptoServiceProvider(); bytValue = System.Text.Encoding.UTF8.GetBytes(TextToHash); bytHash = MD5.ComputeHash(bytValue); MD5.Clear(); return Convert.ToBase64String(bytHash);
}
String ss2 = pwd.substring(0, 16); //取密码原文前16位
String ss3 = pwd.substring(16, pwd.length()); // 所有剩下地字符串
String s1 = ss3;
String s2 = ss2; BASE64Decoder base64decoder = new BASE64Decoder();
byte abyte0[] = base64decoder.decodeBuffer(s2); // 后半字符反编码 MessageDigest messagedigest = MessageDigest.getInstance(
"MD5");
messagedigest.update(abyte0);
messagedigest.update(password.getBytes("UTF8")); //用户提供的密码
byte abyte1[] = messagedigest.digest(); // 用户输入密码MD5加密 // 后半段代码处理
BASE64Encoder base64encoder = new BASE64Encoder();
String s3 = base64encoder.encode(abyte1);
byte abyte2[] = s1.getBytes(); // 前16位
byte abyte3[] = s3.getBytes(); // if (!Arrays.equals(abyte3, abyte2)) {
isauthenticated = false;
logger.info("认证错误!!");
} else {
isauthenticated = true;
logger.info("认证正确!!");
}
有那位师兄用翻译成C#