Skip to content

Commit

Permalink
fix CBC IV
Browse files Browse the repository at this point in the history
  • Loading branch information
odudex committed Nov 19, 2024
1 parent 9cd6e97 commit afd5ec6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/krux/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ def encrypt(self, raw, mode=ucryptolib.MODE_ECB, i_vector=None):
data_bytes = raw.encode("latin-1") if isinstance(raw, str) else raw
if i_vector:
encryptor = ucryptolib.aes(self.key, mode, i_vector)
data_bytes = i_vector + data_bytes
else:
encryptor = ucryptolib.aes(self.key, mode)
encrypted = encryptor.encrypt(
data_bytes + b"\x00" * ((16 - (len(data_bytes) % 16)) % 16)
)
if i_vector:
encrypted = i_vector + encrypted
return base_encode(encrypted, 64)

def decrypt(self, encrypted, mode, i_vector=None):
Expand Down

0 comments on commit afd5ec6

Please sign in to comment.