Advertisement
howtophil

Encrypt, split, and store in QR codes

Dec 20th, 2016
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.66 KB | None | 0 0
  1. #!/bin/bash
  2. #-----------------------------------------------------------------------------
  3. # Use:
  4. # $ ./storeqr.sh "Filename" "YoUR EncRYPtion KeY"
  5. # If you get an error message about parallel not liking -N
  6. # you probably have moreutils installed instead of parallel
  7. # sudo apt-get install parallel
  8. #-----------------------------------------------------------------------------
  9.  
  10. COUNTER=0
  11. IFS=$'\n'
  12.  
  13. for ldata in $( cat $1 |gzip -9 | ccrypt -K "$2" | codegroup | parallel --no-notice -N71 echo) #Low/Default error correction
  14. #for ldata in $( cat $1 |gzip -9 | ccrypt -K "$2" | codegroup | parallel --no-notice -N56 echo) #Medium error correction
  15. #for ldata in $( cat $1 |gzip -9 | ccrypt -K "$2" | codegroup | parallel --no-notice -N40 echo) #Q error correction
  16. #for ldata in $( cat $1 |gzip -9 | ccrypt -K "$2" | codegroup | parallel --no-notice -N30 echo) #High error correction
  17.     do
  18.         let COUNTER+=1
  19.         echo "Working on QRcode $COUNTER"
  20.         PADCOUNT=$(printf "%08d" $COUNTER)
  21.         qrencode -m 8 -o $PADCOUNT.png "$ldata"       #Normal/Low error correction
  22.         #qrencode -l M -o $PADCOUNT.png "$ldata" #Medium error correction
  23.         #qrencode -l Q -o $PADCOUNT.png "$ldata" #Q error correction
  24.         #qrencode -l H -o $PADCOUNT.png "$ldata" #high error correction
  25.         convert $PADCOUNT.png -gravity South -pointsize 15 -annotate +0+0 "$(basename $1) $PADCOUNT" $PADCOUNT.png
  26.     done
  27.  
  28. #-----------------------------------------------------------------------------
  29. # To restore file from qrcodes:
  30. # $ zbarimg -q --raw *.png | sed 's/[0-9]*//g' |codegroup -d |ccrypt -d -K "YoUR EncRYPtion KeY" |gzip -d > out.file
  31. #-----------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement