diff --git a/tronpy/keys/__init__.py b/tronpy/keys/__init__.py index 2f9ae3c..991fce0 100644 --- a/tronpy/keys/__init__.py +++ b/tronpy/keys/__init__.py @@ -1,5 +1,5 @@ import hashlib -import random +import os from collections.abc import ByteString, Hashable from typing import Any, Iterator, Union @@ -274,7 +274,7 @@ def sign_msg_hash(self, message_hash: bytes) -> "Signature": @classmethod def random(cls) -> "PrivateKey": """Generate a random private key.""" - return cls(bytes([random.randint(0, 255) for _ in range(32)])) + return cls(os.urandom(32)) @classmethod def from_passphrase(cls, passphrase: bytes) -> "PrivateKey":