|
@@ -327,8 +327,57 @@ public class WeiXinUserInfoController {
|
|
|
return Integer.parseInt(str, 16);
|
|
|
}
|
|
|
|
|
|
+// public static byte[] strToByte(String data) {
|
|
|
+// data = data.replace(" ", "");
|
|
|
+// int len = data.length();
|
|
|
+// if (!(len % 2 == 0)) {
|
|
|
+// byte[] para = new byte[]{0,0,0,0};
|
|
|
+// return para;
|
|
|
+// }
|
|
|
+// int num = len / 2;
|
|
|
+// byte[] para = new byte[num];
|
|
|
+// for (int i = 0; i < num; i++) {
|
|
|
+// int value = Integer.valueOf(data.substring(i * 2, 2 * (i + 1)), 16);
|
|
|
+// para[i] = (byte) value;
|
|
|
+// }
|
|
|
+// for (byte b : para) {
|
|
|
+//
|
|
|
+// }
|
|
|
+// return para;
|
|
|
+// }
|
|
|
+//
|
|
|
+// private static String crc(byte str[],int len){
|
|
|
+// int crc = 0xFFFF;
|
|
|
+// byte data;
|
|
|
+// for(int i = 0 ; i < len ; i++){
|
|
|
+// data = str[i];
|
|
|
+// for(int j = 0; j < 8; j++){
|
|
|
+// if ((((crc&0x8000)>>8)^(data&0x80))!=0){
|
|
|
+// crc = ((crc << 1) ^ 0x8005);
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// crc <<= 1;
|
|
|
+// }
|
|
|
+// data <<= 1;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// System.out.println("crc"+crc);
|
|
|
+// //结果转换为16进制
|
|
|
+// String result = Integer.toHexString(crc).toUpperCase();
|
|
|
+// if (result.length() != 4) {
|
|
|
+// StringBuffer sb = new StringBuffer("0000");
|
|
|
+// result = sb.replace(4 - result.length(), 4, result).toString();
|
|
|
+// }
|
|
|
+// return result;
|
|
|
+// }
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
String ret = "D5 37";
|
|
|
+ String part = "FA AF 00 07 02 1e 78"+" 1e"+" "+"50"+" 00 3C";
|
|
|
+// byte[] strToByte = strToByte(part);
|
|
|
+// String crc1 = crc(part.getBytes(),strToByte.length);
|
|
|
+// System.out.println("crc"+crc1);
|
|
|
ret = ret.replaceAll(" ", "");
|
|
|
System.out.println(ret);
|
|
|
// int parseInt = Integer.parseInt(ret, 16);
|