//字节码转换成16进制字符串
public static String byte2hex(byte[] b) {
String hs="";
String stmp="";
for (int n=0;n<b.length;n++){
stmp=(java.lang.Integer.toHexString(b[n] & 0XFF));
if (stmp.length()==1)
hs=hs+"0"+stmp;
else hs=hs+stmp;
//if (n<b.length-1) hs=hs+":";
}
return hs.toUpperCase();
}
//16进制字符串转换成字节码
public static byte[] hex2byte(String h) {
byte[] ret = new byte[h.length()/2];
for(int i=0; i<ret.length; i++){
ret[i] = Integer.decode("#"+h.substring(2*i, 2*i+2)).byteValue();
}
return ret;
}
public static String byte2hex(byte[] b) {
String hs="";
String stmp="";
for (int n=0;n<b.length;n++){
stmp=(java.lang.Integer.toHexString(b[n] & 0XFF));
if (stmp.length()==1)
hs=hs+"0"+stmp;
else hs=hs+stmp;
//if (n<b.length-1) hs=hs+":";
}
return hs.toUpperCase();
}
//16进制字符串转换成字节码
public static byte[] hex2byte(String h) {
byte[] ret = new byte[h.length()/2];
for(int i=0; i<ret.length; i++){
ret[i] = Integer.decode("#"+h.substring(2*i, 2*i+2)).byteValue();
}
return ret;
}