• caglararli@hotmail.com
  • 05386281520

Affine cipher grouping in trigrams

Çağlar Arlı      -    39 Views

Affine cipher grouping in trigrams

Assume that you design a new affine cipher where you encrypt three letters at a time, where your alphabet is

{'A':0, 'B':1, 'C':2, 'D':3, 'E':4, 'F':5, 'G':6, 'H':7, 'I':8, 'J':9, 'K':10, 'L':11, 'M':12, 'N':13, 'O':14, 'P':15, 'Q':16, 'R':17, 'S':18, 'T':19, 'U':20, 'V':21, 'W':22, 'X':23, 'Y':24, 'Z':25, '.':26, ',':27, '!':28, ' ':29}.

In other words, you group your plaintext message in trigrams (i.e., three-character words) and encrypt each trigram of the plaintext separately using this affine cipher. For example, if the first three letters of a plaintext is “THE” then it will be encoded as follows

THE ⇒ 19 × 30 × 30 + 7 × 30 + 4 = 17314.

If the number of letters in the plaintext is not a multiple of three, you pad it with the letter “X” at the end until it is a multiple of three. Determine the modulus and the size of the key space.

Here, I initially thought that modulus should be 30^3 to cover every possible number and key space should be euler_totient(30^3) * 30^3. However, I didn't get the encryption part really, for example for THE, should I do D(x) = a*17314+b mod 30^3 and get the characters somehow or should i pick mod30 and for every 3 character 1 character is the output in the cipher like THE = F? Or should it be like THE = WAR. And if its like that, for a=7,b=0 the answer for x=17314 is D(17314)= 13198 mod30^3. Should I break the 13198 in base 30 to find 3 letters? Any ideas?