#!/bin/bash # Script requires Java8, ImageMagic and FinalCrypt export basename="testimage" export finalcrypt="/home/ron/finalcrypt.jar" export imagekey="${basename}key" export password="abc123" export image1="${basename}1.bmp" export image2="${basename}2.bmp" export imagesize="128x128" export bgcolor="white" rm -v ${basename}* # Never add a space in between the var and the "*" or loose all files in the current dir export font="helvetica" export pointsize=96 export text1="A"; export text1x=10; export text1y=90 export text2="B"; export text2x=50; export text2y=110 # Creating the images convert -size "${imagesize}" "xc:${bgcolor}" "${image1}" convert -size "${imagesize}" "xc:${bgcolor}" "${image2}" # Drawing the images convert "${image1}" -font "${font}" -pointsize ${pointsize} -draw "text ${text1x},${text1y} 'A'" "${image1}" convert "${image2}" -font "${font}" -pointsize ${pointsize} -draw "text ${text2x},${text2y} 'B'" "${image2}" # Make copies cp "${image1}" "${image1%.bmp}.orig.bmp" cp "${image2}" "${image2%.bmp}.orig.bmp" # Create Key java -cp ${finalcrypt} rdj.CLUI --create-keyfile -K "${imagekey}" -S "$(stat -c "%s" "${image1}")"; # Key Size equal to target file # Encrypting images with single key java -cp ${finalcrypt} rdj/CLUI --disable-MAC --encrypt --password "${password}" -k "${imagekey}" -t "${image1}" java -cp ${finalcrypt} rdj/CLUI --disable-MAC --encrypt --password "${password}" -k "${imagekey}" -t "${image2}" # Make copies of the encrypted files cp "${image1}.bit" "${image1}.orig.bit" cp "${image2}.bit" "${image2}.orig.bit" # Cross Encrypting one with the other java -cp ${finalcrypt} rdj/CLUI --disable-MAC --encrypt --password "${password}" -k "${image1}.bit" -t "${image2}.bit" java -cp ${finalcrypt} rdj/CLUI --disable-MAC --encrypt --password "${password}" -k "${image2}" -t "${image1}.bit" # Make copies of the cross encrypted files cp "${image1}" "${image1%.bmp}.cross.enc.orig.bmp" cp "${image2}" "${image2%.bmp}.cross.enc.orig.bmp" # Cross Encrypting one with the other # java -cp ${finalcrypt} rdj/CLUI --disable-MAC --encrypt --password "${password}" -k "${image2}" -t "${image1}" # java -cp ${finalcrypt} rdj/CLUI --disable-MAC --encrypt -k "${image1}.bit" -t "${image2}" # Recover bmp header (only when viewing with bmp viewer. Do not recover bmp headers when viewing with veles!) # Get the header imagesize # export headerversion=`exiftool image1.orig.bmp | grep -i "BMP Version" | awk '{ print $5 }'` # export headersize=`wget -qO- 'https://en.wikipedia.org/wiki/BMP_file_format#Bitmap_file_header' | html2text | grep -E "${headerversion}" | head -1 | awk '{ print $1 }'` #echo "Restoring headerversion: ${headerversion} with headersize: ${headersize}" # dd if="${image1%.bmp}.orig.bmp" of="${image1}" bs=${headersize} count=1 conv=notrunc # dd if="${image2%.bmp}.orig.bmp" of="${image2}" bs=${headersize} count=1 conv=notrunc #gwenview "${image1%.bmp}.orig.bmp" "${image2%.bmp}.orig.bmp" "${image1}" "${image2}" & #veles "${imagekey}" "${image1}" "${image2}" &