BadRarFile error opening a rar file protected with a password

291 views Asked by At

iam trying to open an encrypted password and i know the correct password, and its says that : rarfile.BadRarFile: Failed the read enough data: req=592 got=0

here is the code iam using

from rarfile import RarFile
with RarFile('daisy.rar', 'r') as myrar:
    myrar.extractall(pwd='@Daisy_Cloud')

but iam getting and error rarfile.BadRarFile, and i think its related to encrypted file names when encrypting the rarfile because the same code works when i don't encrypt filenames

1

There are 1 answers

2
Sarthak On

You can use rarfile python module.

import rarfile

# Open the RAR file
rar = rarfile.RarFile("path/to/password-protected/file.rar")

# Set the password for the RAR file
rar.setpassword("password")

# Extract all files from the RAR file
rar.extractall()

The rarfile library requires external tool like : unrar (preferred), unar or bsdtar You can install unrar using system package manager sudo apt-get install unrar

Assuming you have a debian based distro.