public static byte[] hex2byte(String str) {
if(str == null)
return null;
str = str.trim();
int len = str.length();
if(len == 0 || len % 2 == 1)
return null;
byte[] b = new byte[len/2];
try{
for(int i = 0; i < str.length(); i+=2){
b[i/2] = (byte)Integer.decode("0x"+str.substring(i,i+2)).intValue();
}
return b;
}catch(Exception e){
return null;
}
}
if(str == null)
return null;
str = str.trim();
int len = str.length();
if(len == 0 || len % 2 == 1)
return null;
byte[] b = new byte[len/2];
try{
for(int i = 0; i < str.length(); i+=2){
b[i/2] = (byte)Integer.decode("0x"+str.substring(i,i+2)).intValue();
}
return b;
}catch(Exception e){
return null;
}
}
int[] a = new int[64];
for (int i = 0; i < b.length; i++){
int t = 128;
for (int j = 0; j < 8; j++){
a[i*8+j] = ((int)b[i]&t)==0?0:1;
t=t>>1;
}
}