dlenski / python-zxing

python wrapper for the ZXing barcode library
GNU Lesser General Public License v3.0
121 stars 36 forks source link

How to get QR Code version, error correction level, and mask? #23

Closed winnie19970218 closed 1 year ago

winnie19970218 commented 2 years ago

Hello, I didn't see any API can get the QR Code version, error correction level, and mask.

dlenski commented 2 years ago

This is a wrapper around the ZXing command-line runner, and it can't extract any information that the ZXing CLR can't show.

any API can get the QR Code version, error correction level, and mask.

I'm curious: why would you want that information while reading a barcode? The whole point of error correction is to be able to transparently and correctly return the originally-encoded string in the face of variable errors while reading the barcode.

winnie19970218 commented 2 years ago

I made a verification system, the decoder needs to know that the QR code is generated by my program when decoding, so I add the detailed information of the QR code to the database when generating the QR code. By comparing the information obtained by the decoder with the database, you can know whether the QR code is unverified. There is a class name called Version.java in [com.google.zxing.qrcode.decoder], this class can get the QR code version.

dlenski commented 2 years ago

I made a verification system, the decoder needs to know that the QR code is generated by my program when decoding, so I add the detailed information of the QR code to the database when generating the QR code. By comparing the information obtained by the decoder with the database, you can know whether the QR code is unverified.

This sounds like it's half steganography, half security through obscurity. Altogether, it seems like it will provide no security, but may prevent the QR codes from being decoded reliably.

The whole point of error correction is that sometimes the QR code will not be read back perfectly.

There is a class name called Version.java in [com.google.zxing.qrcode.decoder], this class can get the QR code version.

Per above, you would have to extend the ZXing command-line runner to output this information to allow python-zxing to read it.