/
2enc
executable file
·51 lines (40 loc) · 1.03 KB
/
2enc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
usage(){
echo "$(tput bold ; tput setaf 6) Usage $0 [number of loop] '[string]'"
echo "If spaces in string protect it with quotes"
echo "Warning big data after loop 5$(tput sgr0)"
exit
}
footer(){
echo -e "\n$(tput setaf 6) CykloDev $(tput setaf 7)pl$(tput setaf 2)3$(tput setaf 7)dg$(tput setaf 2)3$(tput setaf 7) th$(tput setaf 2)3 3$(tput setaf 7)dg$(tput setaf 2)3 \n"
}
if [[ -z ${1} ]] || [[ -z ${2} ]]
then
usage
fi
function enc(){
hex_val=`echo -n "$data" | xxd -ps | sed 's/[[:xdigit:]]\{2\}/\\x&/g'`;
#echo -ne "--> $hex_val";
#echo "";
base64_val=`printf %s $hex_val | base64 | sed 's/=//g'`;
#echo -ne "--> ";
#printf %s $base64_val;
#echo "";
compress=`printf %s $base64_val | gzip -cf | base64 | sed 's/=//g'`;
#echo -ne "--> ";
#printf %s $compress;
#echo "";
data=$compress
}
data=$2
loop=$1
count=0;
while [[ $count -lt $loop ]]
do
echo "$(tput setaf 1)### Loop $count $(tput setaf 4)"
enc "$data";
printf %s $data
echo "$(tput sgr0)"
((count++))
done
footer