Jul-22-2020, 09:43 AM
(This post was last modified: Jul-22-2020, 09:43 AM by SaintFromMsk.)
Hi everyone.
Made a small script for batch file encoding:
But every time i launch it, i get this:
Any advice? (If it'll be a couple of strings of code, and advice where to put it, i'll be very grateful. I'm kinda new to cryptography, worked only on DSM/NLP libraries integration).
Thanks, in advance!
Made a small script for batch file encoding:
import pyAesCrypt import glob import os bufferSize = 512 * 1024 curDir = os.getcwd() password1 = input('\n> pwd: ') print('\n> Onwards...\n\n') for x in glob.glob('test\\**\*', recursive=True): fullpath = os.path.join(curDir, x) fullnewf = os.path.join(curDir, x + '.aes') if os.path.isfile(fullpath): print('>>> Original: \t' + fullpath + '') print('>>> Encrypted, as: \t' + fullnewf + '\n') pyAesCrypt.encryptFile(fullpath, fullnewf, password1, bufferSize) os.remove(fullpath)
But every time i launch it, i get this:
Error:Traceback (most recent call last):
File "encryptFile.py", line 15, in <module>
pyAesCrypt.encryptFile(fullpath, fullnewf, password1, bufferSize)
File "C:\Users\pocto\AppData\Local\Programs\Python\Python37\lib\site-packages\pyAesCrypt\crypto.py", line 49, in encryptFile
encryptStream(fIn, fOut, passw, bufferSize)
File "C:\Users\pocto\AppData\Local\Programs\Python\Python37\lib\site-packages\pyAesCrypt\crypto.py", line 90, in encryptStream
backend=default_backend())
File "C:\Users\pocto\AppData\Local\Programs\Python\Python37\lib\site-packages\cryptography\hazmat\primitives\ciphers\base.py", line 111, in __init__
mode.validate_for_algorithm(algorithm)
File "C:\Users\pocto\AppData\Local\Programs\Python\Python37\lib\site-packages\cryptography\hazmat\primitives\ciphers\modes.py", line 84, in _check_iv_and_key_length
_check_iv_length(self, algorithm)
File "C:\Users\pocto\AppData\Local\Programs\Python\Python37\lib\site-packages\cryptography\hazmat\primitives\ciphers\modes.py", line 77, in _check_iv_length
len(self.initialization_vector), self.name
ValueError: Invalid IV size (64) for CBC.
My guess is that it is induced by differences in encoding (length does not match block size), but i have no idea how to fix it.Any advice? (If it'll be a couple of strings of code, and advice where to put it, i'll be very grateful. I'm kinda new to cryptography, worked only on DSM/NLP libraries integration).
Thanks, in advance!