The Mexican Army Cipher Wheel

With the Mexican Army Cipher Wheel, we have each letter mapped to a range of numeric values. These mappings are defined with a number of…

The Mexican Army Cipher Wheel

With the Mexican Army Cipher Wheel, we have each letter mapped to a range of numeric values. These mappings are defined with a number of rings:

Ref [here]

Disk 1 has values from 01 to 26, Disk 2 from 27 to 52, Disk 3 form 53 to 78, and Disk 4 from 79 to 00 (and with four empty slots. We then use a key to define the position of the disks. If we have an “A”, we map to 01, 27, 53 or 79.

For HELLO, the letter H can be mapped to 08, 34, 60, or 86, and for E we can map to 05, 31, 57 or 83. The position of the disks are represented by four letters. With two rings, we can define a key of “a 20 27”, and where a maps to 20 on the first ring, and 27 on the second ring. For “hello”, we could get a ring and cipher of:

Plaintext:  hello
Wheel: [['20', '21', '22', '23', '24', '25', '26', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19'], ['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', '52']]
Key: a2027
Cipher: 0131383841
Decipher: hello

We do not always have to use “a” in the key. For example, a key of “u063373” will give a mapping for u of “06” on the first ring, “33” on the second ring, and “73” on the third ring:

Plaintext:  hello
Wheel: [['12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11'], ['39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38'], ['53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78']]
Key: u063373
Cipher: 6043236426
Decipher: hello

The code to run this is [here]:

import inqcipher
import sys


chars="abcdefghijklmnopqrstuvwxyz"

nwheels=4
plain='hello'

if (len(sys.argv)>1):
plain=str(sys.argv[1])

if (len(sys.argv)>2):
nwheels=int(sys.argv[2])

print ("Plaintext: ",plain)


plain=plain.lower()

key=inqcipher.generate_key(chars,inqcipher.generate_wheel(chars, nwheels))

wheel = inqcipher.decrypt_key(chars, key, nwheels)

print("Wheel: ",wheel)



print("Key: ",key )

cipher=inqcipher.encrypt(plain, wheel, chars)


print("Cipher: ",cipher)


print("Decipher: ",inqcipher.decrypt(cipher, wheel, chars))

So, can you crack this cipher [here]:

Bob is using an Mexican Army cipher with 4 rings and with a key of 
f024049069084. If the cipher is 021051023075056023044, what is the plaintext?

Hint: It’s an English football team.