is there any way to handle this error with PyPDF2
I have received this error when i wants to merge pdf files
pdfFile=pdfFile.decrypt('')
decrypt return self._decrypt(password)
decrypt raise NotImplementedError("only algorithm code 1 and 2 are supproted. This PDF uses code %s" % encrypt['/V'])
NotImplementedError: only algorithm code 1 and 2 are supported. This PDF uses code 4
Related
I am trying to write code to store a matrix to a variable directly from Matrix Market's website. Below is a sample URL that I'd use:
https://math.nist.gov/pub/MatrixMarket2/Harwell-Boeing/bcsstruc1/bcsstk01.mtx.gz
The example URL will download a bcsstk01.mtx.gz file. I need to extract the bcsstk01.mtx file. Then I need to use MatrixMarket.mmread() so I can save to a variable.
I first tried saving the downloaded file (or URL location) to a variable A = HTTP.get(), but lack of online resources and lack of knowledge led to no results. Then I used HTTP.download() and got the .mtx.gz file, but I can't unzip it. And finally, MatrixMarket.mmread() cannot read .gz files. So I'm stuck with a downloaded file I can't do anything with unless I manually unzip it.
Using the info from link in the comments and some fiddling, I managed to get the following:
using TranscodingStreams, CodecZlib
using Downloads
stream = PipeBuffer()
openstream = TranscodingStream(GzipDecompressor(), stream)
Downloads.download("https://math.nist.gov/pub/MatrixMarket2/Harwell-Boeing/bcsstruc1/bcsstk01.mtx.gz", stream)
for line in eachline(openstream)
println(line)
end
This prints:
%%MatrixMarket matrix coordinate real symmetric
48 48 224
1 1 2.8322685185200e+06
5 1 1.0000000000000e+06
6 1 2.0833333333300e+06
7 1 -3.3333333333300e+03
...
which I suppose is the desired data.
Implement the Caesar Cipher algorithm to encrypt and decrypt a file contents using C language. The cipher basic all use algorithm . Your program should have two C files named encrypt.c and decrypt.c that contains encrypt() and decrypt() functions correspondently for the purpose. In the encryption.c file, use the main() function to take input from a “input.txt” file and store the encrypted message to “enc_msg.txt” file. In the decryption.c file, use the main() function to take input from a “enc_msg.txt” file and store the decrypted message to “dec_msg.txt” file and print the decrypted message in console output as well. The key is 3.
Thanks
Create two .c files encrypt.c and decrypt.c
Create sample data input.txt file
Run your encrypt program to create output file enc_msg.txt from input.txt file
Run your decrypt program to create output file dec_msg.txt from input enc_msg.txt file
So you need to create 3 files encrypt.c decrypt.c and input.txt
And running your programs will generate two more files enc_msg.txt and dec_msg.txt
I am trying to convert a Jupyter notebook to PDF using latex but i am facing the below issues. I believe it is to do with graphs that get generated when i compile my document. The file also contains references. Is there a way to fix this please? Many Thanks for everyone help!
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 691.
! LaTeX Error: Cannot determine size of graphic in Machine_Learning_Project_2_f
iles/Machine_Learning_Project_2_36_1.png (no BoundingBox).
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.719 ...iles/Machine_Learning_Project_2_36_1.png}
? Type <return> to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something, E to edit your file,
1 or ... or 9 to ignore the next 1 to 9 tokens of input,
H for help, X to quit.
? Type <return> to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something, E to edit your file,
1 or ... or 9 to ignore the next 1 to 9 tokens of input,
H for help, X to quit.
? Type <return> to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something, E to edit your file,
1 or ... or 9 to ignore the next 1 to 9 tokens of input,
H for help, X to quit.
? Type <return> to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something, E to edit your file,
1 or ... or 9 to ignore the next 1 to 9 tokens of input,
H for help, X to quit.
?
! Emergency stop.
...
l.719 ...iles/Machine_Learning_Project_2_36_1.png}
Output written on Machine_Learning_Project_2.dvi (8 pages, 69388 bytes).
Transcript written on Machine_Learning_Project_2.log.
You are compiling with latex (tex->dvi), but you should use, e.g., pdflatex as the graphics files are in PNG format.
I'm trying to decrypt a XOR encrypted file, after running the key length test using xortool I got this key: "fallen"..
# python xortool.py -c 00 /cygdrive/c/Users/Me/Desktop/ch3.bmp
The most probable key lengths:
1: 10.6%
3: 11.6%
6: 18.5%
9: 8.8%
12: 13.8%
15: 6.6%
18: 10.4%
24: 8.1%
30: 6.4%
36: 5.2%
Key-length can be 3*n
1 possible key(s) of length 6:
fallen
Whatever is there a way to decipher the file (a bmp file) and get the original one, using tools like openssl or gpg?? Do they have a XOR operation?
Neither OpenSSL nor GPG have such XOR functionality that I'm aware of, however writing a program to do it yourself should be trivial.
Given that you know that the file is a .bmp, you should be able to use this fact to decrypt the file quite easily, especially given that .bmp files have a well defined structure. For example, the first two bytes when decrypted should be 0x42, 0x4D (that's ASCII BM), and the following 4 bytes are the (big-endian) size of the entire file in bytes, so you should be able to get at least 6 bytes of the key immediately.
Since you already have xortool, just use xortool-xor from the xortool distribution:
python xortool/xortool-xor -s fallen /cygdrive/c/Users/Me/Desktop/ch3.bmp > decoded.bmp
Also note that xortool itself saves the decoded output in the xortool_out folder, so after using xortool to find the key, you could just do:
mv xortool_out/0_fallen decoded.bmp
I need a QR code generator that generates 21500 unique serial number with a QR stamp, and export every 1000 code on a one PDF file, so we'll have 22 PDF file.
How can I do that?
Some time ago I've done a similar thing using Python, qrencode and LaTeX. I've modified my old code to fit your needs. I assumed you want A4 pages. The contents of the QR Codes are the PMY00001 to PMY22000 ASCII strings.
#!/usr/bin/env python
import random, base64, string, os, sys
width=7.7
height=7
print "\\documentclass[a4paper,10pt]{report}"
print "\\usepackage[absolute]{textpos}"
print "\\usepackage{nopageno}"
print "\\usepackage{graphicx}"
print "\\setlength{\\TPHorizModule}{1mm}"
print "\\setlength{\\TPVertModule}{1mm}"
print "\\textblockorigin{10mm}{10mm}"
print "\\setlength{\\parskip}{0pt}"
print "\\setlength{\\parindent}{0pt}"
print "\\setlength{\\fboxsep}{0pt}"
print "\\setlength{\\tabcolsep}{0pt}"
print "\\renewcommand{\\baselinestretch}{0.8}"
print ""
print "\\begin{document}"
idx=int(sys.argv[1])
for i in range(0,25):
for j in range(0,40):
b = 'PMY%05d' % idx
f = os.path.join("codes", b + ".png")
ff = os.popen("qrencode -lH -o " + f, "w")
ff.write(b)
ff.close()
print "\\begin{textblock}{" + str(width) + "}(" + str(width * i) + "," + str(height * j) + ")"
print "\\includegraphics[height="+str(height)+"mm]{" + f + "}"
print "\\end{textblock}"
idx=idx+1
print "\\end{document}"
To use it, write it as e.g. qrgen.py, add execution permissions chmod +x qrgen.py, create codes directory: mkdir codes and run ./qrgen.py 0 >codes.tex to generate the codes.tex document and then pdflatex codes.tex to generate codes.pdf file. The 0 argument is the starting serial number.
To get 22 such sheets it's best to use a loop:
for ((i=0;i<22;i++)); do ../qrgen.py $((i*1000+1)) >$i.tex; pdflatex $i.tex; done
Of course this is not the optimal solution - you can probably get a much faster one using Python qrencode library bindings instead of launching external qrencode program and some library for generating PDFs from Python directly instead of using pdflatex.
You can write a script in your language of choice that uses Google's QR code generator in a loop to generate all the codes you'll need and save them to a pdf. You'll need to provide more details if you need a more specific answer.