Warning: mkdir(): No space left on device in /var/www/hottg/post.php on line 59

Warning: file_put_contents(aCache/aDaily/2024-05-22/post/pythondaily/--): Failed to open stream: No such file or directory in /var/www/hottg/post.php on line 72
Django PyCryptodome AES decryption - ValueError: Padding is incorrect @Python Daily
TG Telegram Group & Channel
Python Daily | United States America (US)
Create: Update:

Django PyCryptodome AES decryption - ValueError: Padding is incorrect

I am trying to encrypt incoming files and than decrypt them later. I was following the [documentation](https://www.pycryptodome.org/src/cipher/classic#cbc-mode) for how to use AES with CBC mode for decryption and encryption.

My view for uploading and encrypting file:

@router.post("/upload_files")
def upload_files(request, file: UploadedFile = File(...)):
save_file = operations.aes_encryption(user_id=request.auth.id,file=request.FILES.get('file'))

def aes_encryption(self,user_id,file):
user = UserQueries.get_user(id=user_id)
key: bytes = bytes(user.key, "utf-8")
path: str = user.path

save_file = self._encrypt_file(file,key,path,user)

return save_file

def _encrypt_file(self,file,key,path,user):
file_content = file.read()

cipher = AES.new(key, AES.MODE_CBC)


/r/django
https://redd.it/1c6cewm

Django PyCryptodome AES decryption - ValueError: Padding is incorrect

I am trying to encrypt incoming files and than decrypt them later. I was following the [documentation](https://www.pycryptodome.org/src/cipher/classic#cbc-mode) for how to use AES with CBC mode for decryption and encryption.

My view for uploading and encrypting file:

@router.post("/upload_files")
def upload_files(request, file: UploadedFile = File(...)):
save_file = operations.aes_encryption(user_id=request.auth.id,file=request.FILES.get('file'))

def aes_encryption(self,user_id,file):
user = UserQueries.get_user(id=user_id)
key: bytes = bytes(user.key, "utf-8")
path: str = user.path

save_file = self._encrypt_file(file,key,path,user)

return save_file

def _encrypt_file(self,file,key,path,user):
file_content = file.read()

cipher = AES.new(key, AES.MODE_CBC)


/r/django
https://redd.it/1c6cewm


>>Click here to continue<<

Python Daily






Share with your best friend
VIEW MORE

United States America Popular Telegram Group (US)


Fatal error: Uncaught TypeError: shuffle(): Argument #1 ($array) must be of type array, null given in /var/www/hottg/post.php:344 Stack trace: #0 /var/www/hottg/post.php(344): shuffle() #1 /var/www/hottg/route.php(63): include_once('...') #2 {main} thrown in /var/www/hottg/post.php on line 344