Sha256Hash: direct use of ByteBuffer in hashCode()

A hash code is just an arbitrary number. It doesn't care about signedness and endianess.
This commit is contained in:
Andreas Schildbach 2023-03-24 11:05:50 +01:00
parent d478eb2a55
commit c10cf7ccbe

View File

@ -245,8 +245,8 @@ public class Sha256Hash implements Comparable<Sha256Hash> {
*/
@Override
public int hashCode() {
// Use the last 4 bytes, not the first 4 which are often zeros in Bitcoin.
return (int) ByteUtils.readUint32BE(bytes, LENGTH - (4 + 1));
// use the last 4 bytes, not the first 4 which are often zeros in Bitcoin
return ByteBuffer.wrap(bytes).getInt(LENGTH - Integer.BYTES);
}
@Override