added encryption
This commit is contained in:
parent
ba16317e7c
commit
67b75df273
1 changed files with 40 additions and 16 deletions
|
@ -1,35 +1,55 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ -z "$1" ] || [ -z "$2" ] || [[ $2 != "encode" && $2 != "decode" ]]
|
if [ -z "$1" ] || [ -z "$2" ] || [[ $2 != "encode" && $2 != "decode" && $2 != "encode_enc" ]]
|
||||||
then echo "launch the script with the desired filename and operation"
|
then echo "launch the script with the desired filename and operation"
|
||||||
echo "./AmazonPrimeWhatever.sh FILENAME OPERATION(encode or decode)"
|
echo "./AmazonPrimeWhatever.sh FILENAME OPERATION(encode or decode)"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ $2 = "encode" ] || [ $2 = "encode_enc" ]; then
|
||||||
|
imagejpg="random.jpg"
|
||||||
if [ $2 = "encode" ]; then
|
image="random.DNG"
|
||||||
imagejpg="random.jpg"
|
#generate random image:
|
||||||
image="random.DNG"
|
mx=320;my=256;head -c "$((3*mx*my))" /dev/urandom | convert -depth 8 -size "${mx}x${my}" RGB:- $imagejpg
|
||||||
#generate random image:
|
mv $imagejpg $image
|
||||||
mx=320;my=256;head -c "$((3*mx*my))" /dev/urandom | convert -depth 8 -size "${mx}x${my}" RGB:- $imagejpg
|
imagesize=$(du -b $image | cut -f1)
|
||||||
mv $imagejpg $image
|
if [ $2 = "encode" ]; then
|
||||||
imagesize=$(du -b $image | cut -f1)
|
origsha=$(sha1sum $1 | cut -d " " -f1)
|
||||||
origsha=$(sha1sum $1 | cut -d " " -f1)
|
destimage="FakeKitten_"$imagesize"_"$1"_"$origsha"_"$image
|
||||||
destimage="FakeKitten_"$imagesize"_"$1"_"$origsha"_"$image
|
mv $image $destimage
|
||||||
mv $image $destimage
|
dd if=$1 bs=1M >> "$destimage"
|
||||||
dd if=$1 bs=1M >> "$destimage"
|
echo "encode completed in $destimage"
|
||||||
echo "encode completed in $destimage"
|
fi
|
||||||
|
if [ $2 = "encode_enc" ]; then
|
||||||
|
#
|
||||||
|
gpg --symmetric --cipher-algo AES256 $1
|
||||||
|
#
|
||||||
|
origsha=$(sha1sum $1.gpg | cut -d " " -f1)
|
||||||
|
destimage="FakeKittenENC_"$imagesize"_"$1.gpg"_"$origsha"_"$image
|
||||||
|
mv $image $destimage
|
||||||
|
dd if=$1.gpg bs=1M >> "$destimage"
|
||||||
|
echo "encode completed in $destimage"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ $2 = "decode" ]; then
|
if [ $2 = "decode" ]; then
|
||||||
|
imageconst=$(echo $1 | cut -d "_" -f1)
|
||||||
imagebs=$(echo $1 | cut -d "_" -f2)
|
imagebs=$(echo $1 | cut -d "_" -f2)
|
||||||
origname=$(echo $1 | cut -d "_" -f3)
|
origname=$(echo $1 | cut -d "_" -f3)
|
||||||
origsha=$(echo $1 | cut -d "_" -f4)
|
origsha=$(echo $1 | cut -d "_" -f4)
|
||||||
origimage=$(echo $1 | cut -d "_" -f5)
|
origimage=$(echo $1 | cut -d "_" -f5)
|
||||||
|
|
||||||
dd if=$1 bs=1M skip=$imagebs iflag=skip_bytes > "$origname"
|
dd if=$1 bs=1M skip=$imagebs iflag=skip_bytes > "$origname"
|
||||||
echo "decode completed in $origimage, checking file integrity"
|
|
||||||
|
if [ $imageconst = "FakeKittenENC" ]; then
|
||||||
|
#decrypt the file
|
||||||
|
orignamenogpg=$(echo "$origname" | sed 's/.gpg//')
|
||||||
|
gpg --output $orignamenogpg --decrypt $origname
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "decode completed in $origname, checking file integrity"
|
||||||
echo $origsha" "$origname > $origname".sha1"
|
echo $origsha" "$origname > $origname".sha1"
|
||||||
shaoutput=$(sha1sum -c $origname".sha1")
|
shaoutput=$(sha1sum -c $origname".sha1")
|
||||||
echo $shaoutput
|
echo $shaoutput
|
||||||
|
@ -41,6 +61,10 @@ if [ $2 = "decode" ]; then
|
||||||
rm $origname".sha1"
|
rm $origname".sha1"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
if [ $imageconst = "FakeKittenENC" ]; then
|
||||||
|
#remove the file that contains .gpg at the end
|
||||||
|
rm $origname
|
||||||
|
fi
|
||||||
rm $origname".sha1"
|
rm $origname".sha1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue