~johanvandegriff/unix-shell-programming-revised-edition-programs

unix-shell-programming-revised-edition-programs/obfuscated/decoder/encoder.sh -rw-r--r-- 468 bytes
fc214385Johan Vandegriff added other old scripts, some newer ones too 2 years ago
                                                                                
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
#!/bin/bash
cd `dirname $0`
> tmp
echo -n "Phrase: "
read answer
length=`echo "$answer" | wc -c`
length=`expr "$length" - 1`
echo -n "Offset: "
read offset
i=0
while [ "$i" -lt "$length" ]
do
  i=`expr "$i" + 1`
  number=`echo "$answer" | cut "-c$i-$i"`
  number=`printf "%d\n" "'$number"`
  number=`expr "$number" + "$offset"`
  printf \\$(printf '%03o' "$number") >> tmp
done
echo
echo -n "Phrase: "
cat tmp
echo
echo "Offset: $offset"
echo "Length: $length"
rm tmp