Advertisement
howtophil

Store Data As Codegroup QRcodes (one image)

Mar 25th, 2018 (edited)
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.71 KB | None | 0 0
  1. #!/bin/bash
  2. #-----------------------------------------------------------------------------
  3. # With this bash script your can store any data (text or binary) as a long
  4. # image of qrcodes. Thanks to codegroup, the data is converted to ascii
  5. # letter-only groups of 5 characters. It is then split and converted to
  6. # qrcodes, which are then combined into one image.
  7. #
  8. # You could, of course, encrypt the data before storing it as well.
  9. #
  10. # You'll need bash, gzip, parallel, zbar-tools, codegroup, and imagemagick
  11. # sudo apt-get install bash imagemagick gzip parallel zbar-tools codegroup
  12. #
  13. # Put this script in its own working directory/folder!
  14. # Copy the data file to the working folder.
  15. # Do not run this script on your only copy of some data!
  16. #
  17. # Use the script:
  18. # $ ./qrcg.sh "Filename"
  19. #-----------------------------------------------------------------------------
  20. COUNTER=0
  21. IFS=$'\n'
  22. # Begin for ldata loop
  23. for ldata in $( cat $1 |gzip -9 | codegroup | parallel --no-notice -N60 echo)
  24.     do
  25.         let COUNTER+=1
  26.         echo "Working on QRcode $COUNTER"
  27.         PADCOUNT=$(printf "%08d" $COUNTER)
  28.         qrencode -m 8 -o $PADCOUNT.png "$ldata"
  29.         convert $PADCOUNT.png -gravity South -pointsize 15 -annotate +0+0 "$(basename $1) $PADCOUNT" $PADCOUNT.png
  30.     done
  31. # End for ldata loop
  32. #
  33. # Comment out the following two lines if you just want
  34. # a collection of qrcodes in separate pngs
  35. convert *.png -append inline.png
  36. rm 00*.png
  37. #-----------------------------------------------------------------------------
  38. # To restore file from qrcodes:
  39. # $ zbarimg -q --raw -Sdisable -Sqrcode.enable inline.png | sed 's/[0-9]*//g' | tac |codegroup -d |gzip -d > out.file
  40. #-----------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement