Skip to content

Commit 38ff145

Browse files
committed
adding random bytes to key
1 parent a7cbdd6 commit 38ff145

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

frontera/contrib/messagebus/kafka/transport.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
import hashlib
44
from cachetools import LRUCache
55
from msgpack import Packer, unpackb
6+
from random import randint
7+
from six import MAXSIZE
8+
from struct import pack
9+
10+
11+
def random_bytes():
12+
return pack("L", randint(0, MAXSIZE))
613

714

815
class FramedTransport(object):
@@ -37,6 +44,7 @@ def write(self, key, msg):
3744
seg_count = int(ceil(length / float(seg_size)))
3845
h = hashlib.sha1()
3946
h.update(msg)
47+
h.update(random_bytes())
4048
msg_key = h.digest()
4149
for seg_id in range(seg_count):
4250
seg_msg = msg[seg_id * seg_size: (seg_id + 1) * seg_size]

0 commit comments

Comments
 (0)