DianaOTP
I came across an even better approach to One Time Pad Encryption: Diana.
This system uses letters instead of numbers and makes use of a “speed square” to do the encrypting. You can check out the full YouTube vid from AmRRON here.
Like any One Time Pad, use it once then destroy it. It is completely unbreakable encryption if you keep this one key rule.
The Code
Diana One Time Pad Generator:
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
#!/bin/bash
#
# Generate a random 5-letter key (uppercase A-Z)
key=$(cat /dev/urandom | tr -dc 'A-Z' | head -c 5)
echo "-----------------------------"
echo "| ONE TIME PAD - KEY: $key |"
echo "-----------------------------"
echo
# Print 10 lines of 5-letter groups (first line starts with the key)
for i in {1..10}; do
if (( i == 1 )); then
# First line re-uses the same key
printf "%s %s %s %s %s\n" "$key" \
"$(cat /dev/urandom | tr -dc 'A-Z' | head -c 5)" \
"$(cat /dev/urandom | tr -dc 'A-Z' | head -c 5)" \
"$(cat /dev/urandom | tr -dc 'A-Z' | head -c 5)" \
"$(cat /dev/urandom | tr -dc 'A-Z' | head -c 5)"
else
printf "%s %s %s %s %s\n" \
"$(cat /dev/urandom | tr -dc 'A-Z' | head -c 5)" \
"$(cat /dev/urandom | tr -dc 'A-Z' | head -c 5)" \
"$(cat /dev/urandom | tr -dc 'A-Z' | head -c 5)" \
"$(cat /dev/urandom | tr -dc 'A-Z' | head -c 5)" \
"$(cat /dev/urandom | tr -dc 'A-Z' | head -c 5)"
fi
done
# Generate Several DOTPs at once
#for i in {1..5}; do
#./DOTP.sh >> DOTPs.txt
# done
You can copy & paste this code into a file. Then save it as with a script extension, something like DOTP.sh then just make it executable in the shell.
1
chmod + x DOTP.sh
To run the script and generate the pad, you just run the script in the shell.
1
./DOTP.sh
It also includes some loop code that you can copy into the terminal to generate 5 DOTPs at a time and save them as a text file. The code in the script is commented out so it doesn’t run by default. That code is:
1
2
3
# Generate Several DOTPs at once
for i in {1..5}; do
./DOTP.sh >> DOTPs.txt
The “Speed Square” Generator:
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
#!/usr/bin/env bash
# The separator is 77 characters long
SEP="-----------------------------------------------------------------------------"
echo "$SEP"
# Header row: A B C ... Z (Two spaces between letters)
header=""
for i in {0..25}; do
char=$(printf "\\$(printf '%03o' $((65 + i)))")
if [ $i -eq 25 ]; then
header+="$char"
else
header+="$char "
fi
done
echo "$header"
echo "$SEP"
# Generate Table Rows
for ((row=0; row<26; row++)); do
row_upper=$(printf "\\$(printf '%03o' $((65 + row)))")
line=""
for ((col=0; col<26; col++)); do
# The magic math:
# Start at 25 (z), subtract the row index, then subtract the column index.
# Adding 52 (26*2) ensures the result is positive before the modulo.
val=$(( (25 - row - col + 52) % 26 ))
# Convert result to lowercase (a=97)
lower_char=$(printf "\\$(printf '%03o' $((val + 97)))")
if [ $col -eq 25 ]; then
line+="${row_upper}${lower_char}"
else
line+="${row_upper}${lower_char} "
fi
done
echo "$line"
done
echo "$SEP"
You can save this script as per the instructions above. You can also save this output as a plain text file:
1
./SpeedSquare.sh > SpeedSquare.txt
The Tutorial
The phases of encryption with Diana are:
- Plain Text > Cipher Plain Text > Encrypted Text
1. Run the script to generate a One Time Pad
It spits out a 5 digit key and 5 columns of 5 letters in 10 rows. This OTP will allow you to encrypt a message up to 250 characters. Also run the Speed Square script to generate the cipher table:
2. Plain Text to Cipher Plain Text:
You don’t want to use the key text itself as it is your Pad identifier. So start with the column to the right of the key identifier.
1
2
Plain Text: HAM RADIO ROCKS
Cipher PT: GHO HZAUS HJZOS
You want to format your message into 5 character groups. In this case, our plain text message is two characters shy of the 5. So we will pad them with the letter Z.
1
2
Plain Text: HAMRA DIORO CKSZZ
Cipher PT: GHOHZ AUSHJ ZOSKQ
3. Encrypt the Cipher Plain Text Message
- Using the Speed Square conversion table, convert your message. The Plain Text letter is the top header row, then scroll down the column to the matching Cipher Text letter. The lower case letter is the Encrypted Text.
1
2
3
4
Clean PT: HAM RADIO ROCKS
Formatted: HAMRA DIORO CKSZZ
Cipher PT: GHOHZ AUSHJ ZOSKQ
Encrypted: MSZBA WXTBC YBPQK
This system is incredibly fast and intuitive. It will be less prone to error too because the eye has less tracking across the grid during encryption.
4. Decrypt
To decrypt it is just the opposite procedure. The Encrypted Text is across the top header row. The Cipher Plain Text is down the column. The lower case letter is the Plain Text. Simple!
1
2
3
4
Encrypted: MSZBA WXTBC YBPQK
Cipher PT: GHOHZ AUSHJ ZOSKQ
Formatted: HAMRA DIORO CKSZZ
Clean PT: HAM RADIO ROCKS
73 de VE5REV



