Pikepdf error: "RuntimeError: unable to load openssl legacy provider"

320 views Asked by At

When I try top open a password protected pdf file using pikepdf it runs gives me this error: RuntimeError: unable to load openssl legacy provider

def crack(self, pdf_file="",  numbers_only="n", possible_length=10, **kwargs):
        file_exist = path.exists(pdf_file)
        cracking = True
        if file_exist:
            if numbers_only == "y" or numbers_only == "Y":
                while cracking:
                    password = [choice(NUMBERS) for _ in range(possible_length)]
                    password = "".join(password)
                    print(f"[SYSTEM] Cracking {pdf_file}: {password}", end="\r")
                    try:
                        Pdf.open(pdf_file, password=password)
                        print("PASSWORD FOUND: " + password)
                        cracking = False
                    except:
                        continue

        else:
            print(f"[ERROR] File does not exists ${pdf_file}")
            sys.exit()

I was expecting that it would try and open the file.

1

There are 1 answers

2
Dhruv Sachdev On

You would have to install OpenSSL in your machine If you are on macOS

brew install openssl

for windows you can find installer on their official website - https://slproweb.com/products/Win32OpenSSL.html

for linux based os, use

sudo apt install openssl