cypher_m.a_c_1():
In []: message_2 = cypher_m.a_c_1('Move battalion to the south 39 Degrees.', enc=True)
In []: print(message_2)
Out[]:
[52, 28, 35, 18, 98, 15, 14, 33, 33, 14, 25, 22, 28, 27, 98, 33, 28, 98, 33, 21,
18, 98, 32, 28, 34, 33, 21, 98, 7, 13, 98, 43, 18, 20, 31, 18, 18, 32, 79]
'''
This cypher is substitution-like in the sense that it returns the index of the character
with an applied arithmatic—in this case it adds 3. This is not at all strong and
may be partially deciphered with frequency analysis. It is at least easy to see
a pattern.
To decypher it subtracts three and returns the character at index.
Say we aquired the following message encoded with a_c_1:
'''
In []: message_2_1 = [44, 27, 18, 26, 38, 98, 14, 29, 29, 31, 28, 14, 16, 21, 18,
32, 98, 19, 31, 28, 26, 98, 33, 21, 18, 98, 27, 28, 31, 33,
21, 98, 94, 9, 4, 79, 6, 53, 77, 98, 5, 6, 79, 9, 44, 96, 98,
79, 98, 52, 28, 35, 18, 98, 33, 28, 98, 22, 27, 33, 18, 31,
16, 18, 29, 33, 79]
'''
We can pass it through the function to decode it.
'''
In []: cypher_m.a_c_1(message_2_1, enc=False)
Out[]: 'Enemy approaches from the north {50.2N, 12.5E} . Move to intercept.'
cypher_m.a_c_2():
'''
a_c_2 does pretty much the same but applies arithmatic to different data based on
position.
Say we got message_2_1 encoded with a_c_2:
'''
In []: message_2_1 = cypher_m.a_c_2('Enemy approaches from the north {50.2N, 12.5E} . Move to intercept.', enc=True)
In []: print(message_2_1)
Out[]:
[36, 27, 10, 26, 30, 98, 6, 29, 21, 31, 20, 14, 8, 21, 10, 32, 90, 19, 23, 28, 18,
98, 25, 21, 10, 98, 19, 28, 23, 33, 13, 98, 86, 9, -4, 79, -2, 53, 69, 98, -3, 6,
71, 9, 36, 96, 90, 79, 90, 52, 20, 35, 10, 98, 25, 28, 90, 22, 19, 33, 10, 31, 8,
18, 21, 33, 71]
'''
You can see it is a little more scrambled and may be a little more difficult to
decode if you did not know the alphabet used and steps taken.
'''
cypher_m.a_c_3():
'''
a_c_3 does the same but returns a 3d numpy array.
'''
In []: message_2_1 = cypher_m.a_c_3('Enemy approaches from the north {50.2N, 12.5E} . Move to intercept at dawn.', enc=True)
In []: print(message_2_1)
Out[]:
[[[36 27 10 26 30 98 6 29 21 31 20 14 8 21 10]
[32 90 19 23 28 18 98 25 21 10 98 19 28 23 33]
[13 98 86 9 -4 79 -2 53 69 98 -3 6 71 9 36]
[96 90 79 90 52 20 35 10 98 25 28 90 22 19 33]
[10 31 8 18 21 33 90 14 25 98 9 14 28 27 71]]]
'''
This is where you can get really creative. You can rewrite a_c_3 to apply a bunch
of different array methods to scramble the data before it returns the encyphered
message. Think of it like a rubik's cube but with letters that are substituted as
integers, that you can apply all kinds of mathamatic operations to.
'''