Advertisement
howtophil

Store encrypted file as PNG (color code by pixels)

Dec 22nd, 2016
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.24 KB | None | 0 0
  1. #!/bin/bash
  2. #------------------------------------------------------------
  3. # To encrypt and store a file as a lossless PNG
  4. #
  5. # $ cat fileto.store | ./tocolor.sh imagefilename.png columnsize
  6. #
  7. # You will be prompted for your encryption key/passphrase
  8. #
  9. # You can pipe pretty much anything into it
  10. # so output from tar, echo, etc will all work too.
  11. # See updated version here: http://pastebin.com/nPU1sqsb
  12. #------------------------------------------------------------
  13.  
  14. counter=0
  15. rowcounter=0
  16. if [ ! -n "$2" ]; then
  17.     echo "Setting Column Size to 500"
  18.     columnsize=500
  19. else
  20.     echo "Setting Column Size to $2"
  21.     columnsize=$2
  22. fi
  23. collimit=$(($columnsize-1))
  24.  
  25. ccrypt -e | codegroup | tr '\n' ' '| (
  26.     # while loop
  27.     while IFS= read -r -n1 c
  28.     do
  29.         if [ $counter -gt $collimit ]; then
  30.             counter=0
  31.             let rowcounter+=1
  32.         fi
  33.         case "$c" in
  34.             A) echo -e -n "$counter,$rowcounter: (  0,  0,  1)  #000001  srgb(0,0,1)\n" ;;
  35.             B) echo -e -n "$counter,$rowcounter: (  0,  0,  2)  #000002  srgb(0,0,2)\n" ;;
  36.             C) echo -e -n "$counter,$rowcounter: (  0,  0,  3)  #000003  srgb(0,0,3)\n" ;;
  37.             D) echo -e -n "$counter,$rowcounter: (  0,  0,  4)  #000004  srgb(0,0,4)\n" ;;
  38.             E) echo -e -n "$counter,$rowcounter: (  0,  0,  5)  #000005  srgb(0,0,5)\n" ;;
  39.             F) echo -e -n "$counter,$rowcounter: (  0,  0,  6)  #000006  srgb(0,0,6)\n" ;;
  40.             G) echo -e -n "$counter,$rowcounter: (  0,  0,  7)  #000007  srgb(0,0,7)\n" ;;
  41.             H) echo -e -n "$counter,$rowcounter: (  0,  0,  8)  #000008  srgb(0,0,8)\n" ;;
  42.             I) echo -e -n "$counter,$rowcounter: (  0,  0,  9)  #000009  srgb(0,0,9)\n" ;;
  43.             J) echo -e -n "$counter,$rowcounter: (  0,  0, 16)  #000010  srgb(0,0,16)\n" ;;
  44.             K) echo -e -n "$counter,$rowcounter: (  0,  0, 17)  #000011  srgb(0,0,17)\n" ;;
  45.             L) echo -e -n "$counter,$rowcounter: (  0,  0, 18)  #000012  srgb(0,0,18)\n" ;;
  46.             M) echo -e -n "$counter,$rowcounter: (  0,  0, 19)  #000013  srgb(0,0,19)\n" ;;
  47.             N) echo -e -n "$counter,$rowcounter: (  0,  0, 20)  #000014  srgb(0,0,20)\n" ;;
  48.             O) echo -e -n "$counter,$rowcounter: (  0,  0, 21)  #000015  srgb(0,0,21)\n" ;;
  49.             P) echo -e -n "$counter,$rowcounter: (  0,  0, 22)  #000016  srgb(0,0,22)\n" ;;
  50.             Q) echo -e -n "$counter,$rowcounter: (  0,  0, 23)  #000017  srgb(0,0,23)\n" ;;
  51.             R) echo -e -n "$counter,$rowcounter: (  0,  0, 24)  #000018  srgb(0,0,24)\n" ;;
  52.             S) echo -e -n "$counter,$rowcounter: (  0,  0, 25)  #000019  srgb(0,0,25)\n" ;;
  53.             T) echo -e -n "$counter,$rowcounter: (  0,  0, 32)  #000020  srgb(0,0,32)\n" ;;
  54.             U) echo -e -n "$counter,$rowcounter: (  0,  0, 33)  #000021  srgb(0,0,33)\n" ;;
  55.             V) echo -e -n "$counter,$rowcounter: (  0,  0, 34)  #000022  srgb(0,0,34)\n" ;;
  56.             W) echo -e -n "$counter,$rowcounter: (  0,  0, 35)  #000023  srgb(0,0,35)\n" ;;
  57.             X) echo -e -n "$counter,$rowcounter: (  0,  0, 36)  #000024  srgb(0,0,36)\n" ;;
  58.             Y) echo -e -n "$counter,$rowcounter: (  0,  0, 37)  #000025  srgb(0,0,37)\n" ;;
  59.             Z) echo -e -n "$counter,$rowcounter: (  0,  0, 38)  #000026  srgb(0,0,38)\n" ;;
  60.             " ") echo -e -n "$counter,$rowcounter: (  0,  0, 39)  #000027  srgb(0,0,39)\n" ;;
  61.         esac
  62.         let counter+=1
  63.     done
  64.     let rowcounter+=1
  65.     echo "# ImageMagick pixel enumeration: $columnsize,$rowcounter,255,srgb"
  66.     echo -e -n $color
  67. ) |sed '1h;1d;$!H;$!d;G' | convert -monitor txt: "$1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement