Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions rncryptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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`
Expand Down