diff --git a/src/main/java/org/drjekyll/matomo/tracker/parameters/VisitorId.java b/src/main/java/org/drjekyll/matomo/tracker/parameters/VisitorId.java index 5b8afc1..5d3147f 100644 --- a/src/main/java/org/drjekyll/matomo/tracker/parameters/VisitorId.java +++ b/src/main/java/org/drjekyll/matomo/tracker/parameters/VisitorId.java @@ -38,9 +38,9 @@ public static VisitorId random() { */ public static VisitorId fromHash(long hash) { VisitorId visitorId = new VisitorId(); - for (int i = 0; i < 7; i++) { - visitorId.representation[i] = (byte) (i + hash & 0xFF ); - hash >>= 8; + for (int i = Long.BYTES - 1; i >= 0; i--) { + visitorId.representation[i] = (byte) (hash & 0xFF); + hash >>= Byte.SIZE; } return visitorId; }