这是一段java代码,MD5加密,但小弟不懂java,希望各位提点一二,将此代码用C#写出来,小弟感激不尽。
public static String getKeyedDigest(String strSrc, String key) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(strSrc.getBytes("UTF8")); String result="";
byte[] temp;
temp=md5.digest(key.getBytes("UTF8"));
for (int i=0; i<temp.length; i++){
result+=Integer.toHexString((0x000000ff & temp[i]) | 0xffffff00);
} return result; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); }catch(Exception e)
{
e.printStackTrace();
}
return null;
}
public static String getKeyedDigest(String strSrc, String key) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(strSrc.getBytes("UTF8")); String result="";
byte[] temp;
temp=md5.digest(key.getBytes("UTF8"));
for (int i=0; i<temp.length; i++){
result+=Integer.toHexString((0x000000ff & temp[i]) | 0xffffff00);
} return result; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); }catch(Exception e)
{
e.printStackTrace();
}
return null;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货