Grid Cypher

I was recently attempting to solve the cyphers presented by ToTheArk’s newest video ([Surveillance](https://www.youtube.com/watch?v=cFQKzg-yXgo)) when I came up with an idea (I wasn’t the only one).

“`
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,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,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,A,B,C
“`

That is the 9×9 cypher that formed the basis of my theory. At the time, the message contained only pairs of numbers [0-9]. I went to work brute forcing solutions. When that failed, I tried altering the starting letter of the grid. That failed too. Finally, I tried arbitrarily increasing the size of the grid, at one point getting to 100×100 (but still only using the upper-left most 9×9 as coordinates). These all failed. Ultimately, this didn’t even turn out to be the solution, but when I figured that out I had already written most of the script that I’ve posted below.

“`bash
#!/bin/bash
XM=$1
X=$2
Y=$3
F=$4
CO=$5
if [ “x$F” = x ]
then
F=65
elif [ “x$F” = “x!” ]
then
F=65
BRUTE=1
else
F=$(
echo “ibase=16;
$(echo $F | hexdump | tr [a-z] [A-Z] | awk ‘{print $2}’)” | bc
)
fi
function grid
{
A=0
B=0
GRID=””
Q=$1
while [ $A -lt $Y ]
do
ROW=””
D=$(echo $(($A))|sed ‘s/^\([0-9]\)$/0\1/’)
ROW=”$D”
Z=0
while [ $Z -lt $X ]
do
if [ $Q -gt 90 ]
then
Q=65
fi
ROW=$ROW”…”$(echo -e “\x$(echo “obase=16;ibase=10;$Q”|bc)”)
let “Z++”
let “Q++”
done
LROW=$(echo $ROW | sed ‘s/^..//;s/\.//g;s/\(.\)/\1,/g;s/,$//’)
GRID=”$GRID $LROW”
let “A++”
done
for Z in ${GRID[@]}
do
echo ${Z[@]}
done
}
function decode
{
GRID=($(grid $2))
if [ x$1 = xv ]
then
for ZZ in ${GRID[@]}
do
echo ${ZZ[@]}
done
fi
PHRASE1=””
PHRASE2=””
COORD=($CO)
echo ${#COORD[@]}
for XX in ${COORD[@]}
do
X1=$(($(echo $XX | sed ‘s/,.*//’) – 1))
Y1=$(($(echo $XX | sed ‘s/.*,//’) – 1))
X2=$(($(echo $XX | sed ‘s/,.*//’) – 1))
Y2=$(($(echo $XX | sed ‘s/.*,//’) – 1))
R1=($(echo ${GRID[$Y1]}|sed ‘s/,/ /g’))
R2=($(echo ${GRID[$X2]}|sed ‘s/,/ /g’))
PHRASE1=$PHRASE1″”${R1[$X1]}
PHRASE2=$PHRASE2″”${R2[$Y2]}
done
echo $PHRASE1
echo $PHRASE2
}
#
# Encode
#
function encode
{
GRID=($(grid $2))
if [ x$1 = xv ]
then
for ZZ in ${GRID[@]} do echo ${ZZ[@]} done fi COORD=($(echo $CO|tr [a-z] [A-Z]|tr -dc A-Z |sed ‘s/\(.\)/\1 /g’)) for XX in ${COORD[@]} do YP=$(($RANDOM%${#GRID[@]})) COUNT=$(echo ${GRID[$YP]} | grep $XX |wc -l) while [ $COUNT -lt 1 ] do YP=$(($RANDOM%${#GRID[@]})) COUNT=$(echo ${GRID[$YP]} | grep $XX |wc -l) done LINE=($(echo ${GRID[$YP]}|sed ‘s/,//g;s/\(.\)/\1 /g’)) XP=0 for YY in ${LINE[@]} do if [ $YY = $XX ] then echo -n “$(($XP+1)),$(($YP+1)) ” break else let “XP++” fi done done echo } # # Do Encode # function doencode { if [ “x$CO” != “x” ] then if [ x$BRUTE = x ] then encode v $F else while [ $F -lt 90 ] do encode a $F $3 let “F++” done fi else echo “tta e X Y BASE msg” fi } # # Do Decode # function dodecode { if [ “x$CO” != “x” ] then if [ x$BRUTE = x ] then decode v $F else while [ $F -lt 90 ] do decode a $F let “F++” done fi fi } # # Grid # function dogrid { GRID=($(grid $2)) if [ x$1 = xv ] then for ZZ in ${GRID[@]} do echo ${ZZ[@]} done fi } # # Help # function help { echo tta command x y root message } # # Command Menu Parse # if [ “x$XM” = xe ] then doencode elif [ “x$XM” = xd ] then dodecode elif [ “x$XM” = xg ] then dogrid v $F else help exit fi
“`