From 119857b37171cd5397503d728ef5413a0b9262e7 Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Thu, 28 Sep 2023 09:50:59 +0200 Subject: [PATCH] Remove randbytes for 3.7 compatibility. sigh --- pubnub/crypto_core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubnub/crypto_core.py b/pubnub/crypto_core.py index 8f079750..214e8ced 100644 --- a/pubnub/crypto_core.py +++ b/pubnub/crypto_core.py @@ -1,6 +1,7 @@ import hashlib import json import random +import os from abc import abstractmethod from Cryptodome.Cipher import AES @@ -131,7 +132,7 @@ def __init__(self, cipher_key): self.cipher_key = cipher_key def get_initialization_vector(self) -> bytes: - return random.randbytes(16) + return os.urandom(16) def get_secret(self, key) -> str: return hashlib.sha256(key.encode("utf-8")).digest()