From b5e5437f41f6c507ad9d92663f13766110e9fb09 Mon Sep 17 00:00:00 2001 From: Daniel Heid Date: Mon, 30 Oct 2023 18:36:21 +0100 Subject: [PATCH] Fix long to bytes conversion --- .../org/drjekyll/matomo/tracker/parameters/VisitorId.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; }