Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pyAesCrypt issues
#1
Hi everyone.

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!
Reply
#2
Fixed by doing a clean install of all corresponding libraries.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020