Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/main/java/com/github/emboss/siphash/SipHash.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ private static long lastBlock(byte[] data, int iter) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one more change for this PR:

diff --git a/src/main/java/com/github/emboss/siphash/SipHash.java b/src/main/java/com/github/emboss/siphash/SipHash.java
index 9f31287..00c4640 100644
--- a/src/main/java/com/github/emboss/siphash/SipHash.java
+++ b/src/main/java/com/github/emboss/siphash/SipHash.java
@@ -21,7 +21,7 @@ public class SipHash {
     }
 
     private static long lastBlock(byte[] data, int iter) {
-        long last = ((long) data.length) << 56;
+        long last = (((long) data.length) & 0xff) << 56;
         int off = iter * 8;
 
         switch (data.length % 8) {

switch (data.length % 8) {
case 7:
last |= ((long) data[off + 6]) << 48;
last |= (((long) data[off + 6]) & 0xff) << 48;
case 6:
last |= ((long) data[off + 5]) << 40;
last |= (((long) data[off + 5]) & 0xff) << 40;
case 5:
last |= ((long) data[off + 4]) << 32;
last |= (((long) data[off + 4]) & 0xff) << 32;
case 4:
last |= ((long) data[off + 3]) << 24;
last |= (((long) data[off + 3]) & 0xff) << 24;
case 3:
last |= ((long) data[off + 2]) << 16;
last |= (((long) data[off + 2]) & 0xff) << 16;
case 2:
last |= ((long) data[off + 1]) << 8;
last |= (((long) data[off + 1]) & 0xff) << 8;
case 1:
last |= (long) data[off];
last |= ((long) data[off]) & 0xff;
break;
case 0:
break;
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/github/emboss/siphash/UnsignedInt64.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public static long binToInt(byte[] b) {
}

public static long binToIntOffset(byte[] b, int off) {
return ((long) b[off ]) |
((long) b[off + 1]) << 8 |
((long) b[off + 2]) << 16 |
((long) b[off + 3]) << 24 |
((long) b[off + 4]) << 32 |
((long) b[off + 5]) << 40 |
((long) b[off + 6]) << 48 |
((long) b[off + 7]) << 56;
return (((long) b[off ]) & 0xff) |
(((long) b[off + 1]) & 0xff) << 8 |
(((long) b[off + 2]) & 0xff) << 16 |
(((long) b[off + 3]) & 0xff) << 24 |
(((long) b[off + 4]) & 0xff) << 32 |
(((long) b[off + 5]) & 0xff) << 40 |
(((long) b[off + 6]) & 0xff) << 48 |
(((long) b[off + 7]) & 0xff) << 56;
}

public static void intToBin(long l, byte[] b) {
Expand Down