From 77e2a90d3de50b5f165a994f72fb04e52dff26a9 Mon Sep 17 00:00:00 2001 From: Alin Radut Date: Mon, 2 Dec 2024 19:04:34 +0200 Subject: [PATCH 1/2] fix: byte check on python3 --- rncryptor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rncryptor.py b/rncryptor.py index 83d6bea..664e164 100644 --- a/rncryptor.py +++ b/rncryptor.py @@ -113,12 +113,12 @@ def decrypt(self, data, password): # data doesn't even match the required header + hmac length raise DecryptionError("Invalid length") - version = data[0] + version = data[:1] if not version == b'\x03': # required version is version 3 raise DecryptionError("Unsupported version") - options = data[1] + options = data[1:2] if not options == b'\x01': # when using keys options should be `0` @@ -153,13 +153,13 @@ def decrypt_with_keys(self, data, hmac_key, encryption_key): # data doesn't even match the required header + hmac length raise DecryptionError("Invalid length") - version = data[0] + version = data[:1] if not version == b'\x03': # required version is version 3 raise DecryptionError("Unsupported version") - options = data[1] + options = data[1:2] if not options == b'\x00': # when using keys options should be `0` From 9b0427d8b1426a2198eaeec6f01a200209c03489 Mon Sep 17 00:00:00 2001 From: Alin Radut Date: Mon, 2 Dec 2024 19:16:42 +0200 Subject: [PATCH 2/2] chore: add hmac_salt line to readme --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 5a91dff..3e6d959 100644 --- a/README.rst +++ b/README.rst @@ -41,6 +41,7 @@ Usage # encrypt_with_keys and decrypt_with keys functions encryption_salt = '...' # 8 random bytes + hmac_salt = '...' # 8 random bytes encryption_key = rncryptor.make_key(password, encryption_salt) hmac_key = rncryptor.make_key(password, hmac_salt) encrypted_data = rncryptor.encrypt_with_keys(data, hmac_key, encryption_key)