create a list of word strings by reading this file. Then loop over each word in this list, passing it to the decrypt() method. If this method returns the integer 0, the password was wrong and your program should continue to the next password. If decrypt() returns 1, then your program should break out of the loop and print the hacked password. You should try both the uppercase and lower-case form of each word.
This dictionary.txt file contains words in capital letters.
my code:
This dictionary.txt file contains words in capital letters.
my code:
import PyPDF2 pdfFile = open('reverse.pdf', 'rb') pdfReader = PyPDF2.PdfFileReader(pdfFile) pdfWriter = PyPDF2.PdfFileWriter() for pageNum in range(pdfReader.numPages): pdfWriter.addPage(pdfReader.getPage(pageNum)) pdfWriter.encrypt('inside') resultPdf = open('encryptedreverse.pdf', 'wb') pdfWriter.write(resultPdf) resultPdf.close() print(pdfReader.isEncrypted) helloDict = open('dictionary.txt') helloDictCont = helloDict.read().splitlines() liDict = [] for word in helloDictCont: liDict.append(word) PdfFile2 = open('encryptedreverse.pdf', 'rb') pdfReader2 = PyPDF2.PdfFileReader(PdfFile2) print(pdfReader2.isEncrypted) for word in liDict: if pdfReader2.decrypt(word) == 1: break print(word) elif pdfReader2.decrypt(word.lower()) == 1: break print(word) else: passAs you can see I first encrypted a file and then wrote a code that should decrypt it. The output is that it prints True and then after minutes of work it doesn't give anything. What am I doing wrong?