【发布时间】:2010-12-08 19:23:17
【问题描述】:
我尝试比较 2 字节数组。
字节数组 1 是一个带有 sha1 哈希的最后 3 个字节的数组:
private static byte[] sha1SsidGetBytes(byte[] sha1)
{
return new byte[] {sha1[17], sha1[18], sha1[19]};
}
字节数组 2 是一个数组,我用来自十六进制字符串的 3 个字节填充:
private static byte[] ssidGetBytes(String ssid)
{
BigInteger ssidBigInt = new BigInteger(ssid, 16);
return ssidBigInt.toByteArray();
}
怎么可能这样比较:
if (Arrays.equals(ssidBytes, sha1SsidGetBytes(snSha1)))
{
}
大部分时间都有效,但有时无效。字节顺序?
例如对于“6451E6”(十六进制字符串)它工作正常,对于“ABED74”它没有......
【问题讨论】:
-
您查看过调试器中包含的字节数组吗?您是否可能遇到带符号字节的问题?
-
如何查看他们是否已签名?