capacitor-community / barcode-scanner

A fast and efficient (QR) barcode scanner for Capacitor
MIT License
437 stars 169 forks source link

binary-mode QR scanning #148

Closed wombatslayer closed 1 year ago

wombatslayer commented 2 years ago

Is your feature request related to a problem? Please describe. When scanning a QR code that uses byte mode encryption, the data which is returned is incorrect. On Android, I get a string encoding of the byte data, eg. "��\t�@\u00", from which I cannot recover the original bytes; on iPhone, the native barcode scanner returns a read error.

Describe the solution you'd like I would like to have an additional scan option which allows me to specify the read-mode of the QR code, ie. binary. Then, the results.content will be either a unit8array containing the bytes in a raw form, or a base64url encoding thereof.

Describe alternatives you've considered We have considered encoding our binary data as bae64url, and then encoding the result text into the QR code. This is inefficient because we then need 8bits to encode each base64url character, instead of 6.

wombatslayer commented 2 years ago

Having a closer look. It appears that com.google.zxing does expose a method called getRawBytes(), which should do what I need on Android. I'll get a PR going in the next few days.

wombatslayer commented 2 years ago

For iOS, this blog post seems to hold promising information: https://ristkof.be/posts/qr-codes-binary-on-ios.html

thegnuu commented 1 year ago

@wombatslayer This seems not really possible with the new ml-kit implementation as far as I was able to research, I am closing this for now.