python-3.x Pikepdf错误:“运行时间错误:无法加载openssl旧版提供程序”

nwlls2ji  于 2023-10-21  发布在  Python
关注(0)|答案(1)|浏览(199)

当我尝试使用pikepdf打开一个受密码保护的pdf文件时,它会运行给我这个错误:运行时错误:无法加载openssl遗留提供程序

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()

我以为它会尝试打开文件。

50few1ms

50few1ms1#

如果你在macOS上,你必须在你的机器上安装OpenSSL

brew install openssl

对于Windows,您可以在其官方网站上找到安装程序-https://slproweb.com/products/Win32OpenSSL.html
对于基于Linux的操作系统,使用

sudo apt install openssl

相关问题