zxing-cpp icon indicating copy to clipboard operation
zxing-cpp copied to clipboard

zxing command line utility should not add newline to output on stdout

Open jose1711 opened this issue 4 years ago • 0 comments

Consider the following example:

  • prepare input data

    $ dd if=/dev/urandom bs=1 count=1000 of=random_data
    1000+0 records in
    1000+0 records out
    1000 bytes (1.0 kB) copied, 0.00658353 s, 152 kB/s
    
    $ md5sum random_data
    13952535b138a595209fc2296330c3de  random_data
    
  • generate qr code using qrencode

    $ qrencode -8 -r random_data -o random_data_qr.png
    
  • read data back using zxing and compare against the original

    $ zxing random_data_qr.png > random_data_decoded
    
    $ zxing random_data_qr.png | md5sum -
    643d5e12ba211ceb3edc3ae8a0492a9c  -
    
    $ ls -l random_data random_data_decoded
    -rw-r--r-- 1 jose jose 1000 Jan  2 09:11 random_data
    -rw-r--r-- 1 jose jose 1001 Jan  2 09:13 random_data_decoded
    

    realize that input and output is not equal.

  • strip the last character (newline) from the output

    $ truncate --size=-1 random_data_decoded
    $ md5sum random_data_decoded
    13952535b138a595209fc2296330c3de  random_data_decoded
    

    now the sum matches.

My expectation is that zxing does not add the newline character arbitrarily or at least has an option to disable such behavior.

jose1711 avatar Jan 02 '20 08:01 jose1711