将java的代码转换成vb.net的代码 10
请各位大侠帮帮忙,急切等待中,代码如下:importjava.security.MessageDigest;importjava.security.NoSuchAlgor...
请各位大侠帮帮忙,急切等待中,代码如下:
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class KeyedDigestMD5 {
public static byte[] getKeyedDigest(byte[] buffer, byte[] key) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(buffer);
return md5.digest(key);
} catch (NoSuchAlgorithmException e) {
}
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).substring(6);
}
return result;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}catch(Exception e)
{
e.printStackTrace();
}
return null;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String mi;
String s = "hf1000";
//第二个参数请填空字符串
mi=KeyedDigestMD5.getKeyedDigest(s,"");
System.out.println("mi:"+mi);
}
} 展开
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class KeyedDigestMD5 {
public static byte[] getKeyedDigest(byte[] buffer, byte[] key) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(buffer);
return md5.digest(key);
} catch (NoSuchAlgorithmException e) {
}
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).substring(6);
}
return result;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}catch(Exception e)
{
e.printStackTrace();
}
return null;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String mi;
String s = "hf1000";
//第二个参数请填空字符串
mi=KeyedDigestMD5.getKeyedDigest(s,"");
System.out.println("mi:"+mi);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询