java wireshark 16进制复制的字符串转换字节数组

时间:2023-01-11 14:06:12

String a="880a4336fd85a87ef39cfaa8c072d8899578d9c4c409ea78161edd41b52f96f377bf162a1bfd4be8e90022354a983d3c426bf34439719c89407ca706449171413dd6e08cb9792ba8965227e6df8e182d1821f67758b7309bc7d6dce1593c07fbb0c85e50c0ef3c04a4acf9ed09f7126b96b7fc1dbbe45fc36724e87d8bc28ad265c540053967a58d60e4ec34cd1efda2537ccefc1225629a64f4f1876f0c7471f783576884d86d2faa3f4975f3399c8e0357d49ad07ca4320fb8151867e698e3849bf4d971020b7d76c1e84bb58358c5";
byte[] bytes=new byte[a.length()/2];
for (int i=0;i<a.length()/2;i++)
{
String temp=a.substring(i*2,(i+1)*2);
// System.out.println("字符串:"+temp);
byte v = (byte) Integer.parseInt(temp, 16);
bytes[i]=v;
}
String decode=test.decode(str.getBytes(), bytes);