How do I use dmtxread to read a scanned data matrix?
2
votes
2
answers
3858
views
I am trying to read a data matrix which I have generated from a private 2096-bit encrypted RSA key.
The key was generated using
I now wanted to use the following command to recreate my private key:
dmtxread /path/to/image.jpg | paperkey --pubring ~/.gnupg/pubring.gpg > my-regenerated-private-key.gpg
However, the command
Clearly it's struggling with some of the boundaries, but I'm not sure why or how to make
gpg
and printed to PDF with the following command:
gpg --export-secret-key MY_PRIVATE_KEY_ID | paperkey --output-type raw | dmtxwrite -e 8 -f PDF > ~/key.pdf
I then printed key.pdf
and scanned it, producing the following jpg file:

dmtxread
prints nothing to stdout
and returns 1
. I have tried tinkering with the error correction by using -C 10000
, reducing the tolerance for rotation by using -q 5
, and increasing the canvas size of the image to increase the number of blank pixels to the left and right of the matrix. I also tried with a larger resolution scan (I don't know the DPI, but it was 4MB and the squares were very well defined) and adjusting the contrast tolerance using -t 20
and -t 5
, all with the same result (although I had to skip pixels using -S 5
with this large file to get it to finish in < 30 minutes).
I tried using --verbose
but nothing was printed to stdout
(or any diagnostic file as far as I could tell).
I have also tried the -D
option to produce a diagnostic image. I'm not really sure what to make of the result though:

dmtxread
more robust.
My next step was going to be attempting to decrypt a dummy file using the recovered private key, but obviously I didn't get that far.
It's disappointing that this is so difficult; if there is no easy way to do this with the command-line libdmtx
tools, maybe there is another tool that can do this for me out of the box?
_Important_: it goes without saying that I would never use this private key for any actual encrypting, now that I've shared it online. You should never share your private key.
Asked by quant
(4251 rep)
Jan 3, 2016, 04:29 AM
Last activity: Dec 30, 2016, 09:35 AM
Last activity: Dec 30, 2016, 09:35 AM