【发布时间】:2011-12-29 22:26:54
【问题描述】:
我正在尝试选择字节数组中最后一个字节的低 4 位。这就是我之前在 PHP 中完成的方式,但我是 Java 新手。
$lower4bit = substr($bytes[19], -1);
//Convert the hex to decimal to get the offset value
$offset = hexdec($lower4bit);
//Select the value of the 4 bytes starting at the offset
$joinedArray = implode(array_slice($bytes, $offset, 4));
谁能指出我使用 Java 的正确方向?
【问题讨论】:
-
我没有时间给出完整的答案,但请记住……在 PHP 中,“数组”是数组、列表、地图和各种其他东西。在 Java 中,它们并没有合二为一。
-
即使在 PHP 中,这也是非常错误的做法。
$lower4bit = $bytes[19] & 0x0F;
标签: java bytearray one-time-password