该行的含义:buf = ((buf << 11) | (buf >>> 21));
meaning of the line: buf = ((buf << 11) | (buf >>> 21));
我使用 this 密码学家庭作业代码,但无法理解第 59 行
感谢各位帮手
同上;向左旋转 11 位以获得 int
值。
低 21 位向上移动 11,而高 11 位向下移动 21。
这是哈希中使用的一种常见模式,因为它可以快速重新排列数字的位而不会丢失随机性。
Returns the value obtained by rotating the two's complement binary representation of the specified int value right by the specified number of bits. (Bits shifted out of the right hand, or low-order, side reenter on the left, or high-order.)
Note that right rotation with a negative distance is equivalent to left rotation: rotateRight(val, -distance) == rotateLeft(val, distance). Note also that rotation by any multiple of 32 is a no-op, so all but the last five bits of the rotation distance can be ignored, even if the distance is negative: rotateRight(val, distance) == rotateRight(val, distance & 0x1F).
Returns:
the value obtained by rotating the two's complement binary representation of the specified int value right by the specified number of bits.
public static int rotateRight(int i, int distance) {
return (i >>> distance) | (i << -distance);
}
我使用 this 密码学家庭作业代码,但无法理解第 59 行
感谢各位帮手
同上;向左旋转 11 位以获得 int
值。
低 21 位向上移动 11,而高 11 位向下移动 21。
这是哈希中使用的一种常见模式,因为它可以快速重新排列数字的位而不会丢失随机性。
Returns the value obtained by rotating the two's complement binary representation of the specified int value right by the specified number of bits. (Bits shifted out of the right hand, or low-order, side reenter on the left, or high-order.)
Note that right rotation with a negative distance is equivalent to left rotation: rotateRight(val, -distance) == rotateLeft(val, distance). Note also that rotation by any multiple of 32 is a no-op, so all but the last five bits of the rotation distance can be ignored, even if the distance is negative: rotateRight(val, distance) == rotateRight(val, distance & 0x1F).
Returns: the value obtained by rotating the two's complement binary representation of the specified int value right by the specified number of bits.
public static int rotateRight(int i, int distance) {
return (i >>> distance) | (i << -distance);
}