Store encrypted file as PNG (2017/01/15) howtophil Jan 15th, 2017 ( edited ) 367 Never 367Never

Not a member of Pastebin yet? Sign Up , it unlocks many cool features!

rawdownloadcloneembedreportprint Bash 2.70 KB #!/bin/bash #------------------------------------------------------------ # To encrypt and store a file as a lossless PNG # # $ cat fileto.store | ./tocolor.sh imagefilename.png columnsize # # You will be prompted for your encryption key/passphrase # # You can pipe pretty much anything into it # so output from tar, echo, etc will all work too. #------------------------------------------------------------ #----------------------------------------- # Initialize some counters #----------------------------------------- counter = 0 rowcounter = 0 colorcounter = 0 #----------------------------------------- # Initialize color arrays # and cache some math to make things # run faster. #----------------------------------------- declare -A colorarray declare -A fabcolors alphaarray = ( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ) # Blues and purples theme precolorarray = ( 000080 00008B 0000CD 0000FF 191970 1E90FF 4169E1 483D8B 4B0081 4B0182 6A5ACD 7B68EE 800080 8A2BE1 8A2CE2 8B008B 9370DB 9400D3 9932CC BA55D3 D8BFD8 DA70D6 DDA0DD E6E6FA EE82EE FF11FF FF00FF ) # Or dark greys to look black instead # precolorarray=(000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 000013 000014 000015 000016 000017 000018 000019 000020 000021 000022 000023 000024 000025 000026) for oneletter in " ${alphaarray[@]} " do # Fill the colorarray colorarray [ " $oneletter " ] = " ${precolorarray[$colorcounter]} " let colorcounter+= 1 # Fill the fabcolors array hexinput = ${colorarray[$oneletter]} a = ` echo $hexinput | cut -c- 2 ` b = ` echo $hexinput | cut -c3- 4 ` c = ` echo $hexinput | cut -c5- 6 ` r = ` echo "ibase=16; $a " | bc ` g = ` echo "ibase=16; $b " | bc ` b = ` echo "ibase=16; $c " | bc ` fabcolors [ $oneletter ] = "( $r , $g , $b ) # $hexinput srgb( $r , $g , $b )

" done #----------------------------------------- # How wide did we set the image? # or just default to 500 pixels wide #----------------------------------------- if [ ! -n "$2" ] ; then echo "Setting Column Size to 500" columnsize = 500 else echo "Setting Column Size to $2" columnsize = $2 fi collimit =$ ( ( $columnsize - 1 ) ) #----------------------------------------- # start encrypting, encoding, and # building the PNG. #----------------------------------------- ccrypt -e | codegroup | tr '

' ' ' | ( # while loop while IFS = read -r -n1 theletter do if [ $counter -gt $collimit ] ; then counter = 0 let rowcounter+= 1 fi if [ [ $theletter = * [ ! \ ] * ] ] ; then echo -e -n " $counter , $rowcounter : ${fabcolors[$theletter]} " let counter+= 1 fi done let rowcounter+= 1 echo " ImageMagick pixel enumeration: $columnsize , $rowcounter ,255,srgb" ) | sed '1h;1d;$!H;$!d;G' | convert -monitor txt: "$1"

RAW Paste Data

#!/bin/bash #------------------------------------------------------------ # To encrypt and store a file as a lossless PNG # # $ cat fileto.store | ./tocolor.sh imagefilename.png columnsize # # You will be prompted for your encryption key/passphrase # # You can pipe pretty much anything into it # so output from tar, echo, etc will all work too. #------------------------------------------------------------ #----------------------------------------- # Initialize some counters #----------------------------------------- counter=0 rowcounter=0 colorcounter=0 #----------------------------------------- # Initialize color arrays # and cache some math to make things # run faster. #----------------------------------------- declare -A colorarray declare -A fabcolors alphaarray=(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) # Blues and purples theme precolorarray=(000080 00008B 0000CD 0000FF 191970 1E90FF 4169E1 483D8B 4B0081 4B0182 6A5ACD 7B68EE 800080 8A2BE1 8A2CE2 8B008B 9370DB 9400D3 9932CC BA55D3 D8BFD8 DA70D6 DDA0DD E6E6FA EE82EE FF11FF FF00FF) # Or dark greys to look black instead # precolorarray=(000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 000013 000014 000015 000016 000017 000018 000019 000020 000021 000022 000023 000024 000025 000026) for oneletter in "${alphaarray[@]}" do # Fill the colorarray colorarray["$oneletter"]="${precolorarray[$colorcounter]}" let colorcounter+=1 # Fill the fabcolors array hexinput=${colorarray[$oneletter]} a=`echo $hexinput | cut -c-2` b=`echo $hexinput | cut -c3-4` c=`echo $hexinput | cut -c5-6` r=`echo "ibase=16; $a" | bc` g=`echo "ibase=16; $b" | bc` b=`echo "ibase=16; $c" | bc` fabcolors[$oneletter]="( $r, $g, $b) #$hexinput srgb($r,$g,$b)

" done #----------------------------------------- # How wide did we set the image? # or just default to 500 pixels wide #----------------------------------------- if [ ! -n "$2" ]; then echo "Setting Column Size to 500" columnsize=500 else echo "Setting Column Size to $2" columnsize=$2 fi collimit=$(($columnsize-1)) #----------------------------------------- # start encrypting, encoding, and # building the PNG. #----------------------------------------- ccrypt -e | codegroup | tr '

' ' '| ( # while loop while IFS= read -r -n1 theletter do if [ $counter -gt $collimit ]; then counter=0 let rowcounter+=1 fi if [[ $theletter = *[!\ ]* ]]; then echo -e -n "$counter,$rowcounter: ${fabcolors[$theletter]}" let counter+=1 fi done let rowcounter+=1 echo " ImageMagick pixel enumeration: $columnsize,$rowcounter,255,srgb" ) |sed '1h;1d;$!H;$!d;G' | convert -monitor txt: "$1"