From b59b11445ff50b0e12f6f2906feeac7ec3343369 Mon Sep 17 00:00:00 2001 From: Fulong Sun <2051806+SunFulong@users.noreply.github.com> Date: Sun, 14 Apr 2024 02:14:56 +0800 Subject: [PATCH] Both MASK and random number using big-endian byte order --- autobahn/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autobahn/util.py b/autobahn/util.py index c3d3f4786..a66b26f28 100644 --- a/autobahn/util.py +++ b/autobahn/util.py @@ -279,7 +279,7 @@ def __next__(self): # 8 byte mask with 53 LSBs set (WAMP requires IDs from [1, 2**53] -_WAMP_ID_MASK = struct.unpack("@Q", b"\x00\x1f\xff\xff\xff\xff\xff\xff")[0] +_WAMP_ID_MASK = struct.unpack(">Q", b"\x00\x1f\xff\xff\xff\xff\xff\xff")[0] def rid(): @@ -298,7 +298,7 @@ def rid(): :returns: A random integer ID. :rtype: int """ - return struct.unpack("@Q", os.urandom(8))[0] & _WAMP_ID_MASK or 2 ** 53 + return struct.unpack(">Q", os.urandom(8))[0] & _WAMP_ID_MASK or 2 ** 53 # noinspection PyShadowingBuiltins