/**
* CRC16校验码获取
* @author Xjt
*/
public class CRCUtils {
public static String getCRC(String str){
String[] str1 = str.split(" ");
int n = 0;
for(int i=0;i<str1.length;i++){
n ^= Integer.parseInt(str1[i],16);
}
String n16 = "";
while(n != 0) {
int i = n % 16;
n16 = to16(i) + n16;
n = n / 16;
}
return n16;
}
/**
* HEX转换
* @param i
* @return
*/
private static char to16(int i) {
if(i <= 9 && i >= 0)
return (char)(i + '0');
else
return (char)(i - 10 + 'A');
}
}