diff --git a/magneticod/magneticod/bittorrent.py b/magneticod/magneticod/bittorrent.py index 472dae4..f499d0b 100644 --- a/magneticod/magneticod/bittorrent.py +++ b/magneticod/magneticod/bittorrent.py @@ -19,6 +19,7 @@ import math import socket import random import typing +import os from . import bencode @@ -287,4 +288,4 @@ class DisposablePeer: @staticmethod def __random_bytes(n: int) -> bytes: - return random.getrandbits(n * 8).to_bytes(n, "big") + return os.urandom(n) diff --git a/magneticod/magneticod/dht.py b/magneticod/magneticod/dht.py index a4437c4..8362d34 100644 --- a/magneticod/magneticod/dht.py +++ b/magneticod/magneticod/dht.py @@ -19,6 +19,7 @@ import logging import random import socket import typing +import os from . import bencode @@ -244,7 +245,7 @@ class SybilNode: @staticmethod def __random_bytes(n: int) -> bytes: - return random.getrandbits(n * 8).to_bytes(n, "big") + return os.urandom(n) def __build_FIND_NODE_query(self, id_: bytes) -> bytes: """ BENCODE IMPLEMENTATION