3

My friend was experimenting with the encryption methods (self-made) to encrypt text using ASCII map. He wanted to try this idea whether this encryption can be broken and so shared an encrypted text along with some examples with me. They are as follows.

Encrypted text:

13 28 32 18 100 25 96 47 88 0 44 104 5 47 93 19 73 104 16 102 102 11 18 123 72 94 38 80 29 17 111 110 104 122 114 20 126 127 45 55 30 98 60 16 35 16 52 5 24 107 15 24 13 124 79 105 0 61 46 84 112 9 9 97 13 127 0 30 55 19 102 68 30 105 10 82 54 83 29 117 119 38 29 87 74 66 99 99 77 70 81 69 25 64 51 117 87 71 8 120 43 113 57 110 80 108 117 22 41 83 125 30 76 96 0 49 110 115 37 26 46 67 18 96 81 110 79 49 59 109 5 95 72 34 71 108 60 48 26 55 71 73 68 92 90 120 33 37 64 64 88 28 65 20 7 60 83 96 16 50 110 36 105 102 18 40 46 76 80 55 55 125 103 35 111 40 2 126 22 3 87 126 82 108 126 61 108 56 31 52 69 18 114 39 84 84 55 98 70 26 118 3 102 89 110 73 104 72 25 38 15 126 81 6 88 40 50 35 13 40 65 2 40 33 2 78 110 7 12 119 59 30 52 87 30 36 15 100 39 92 90 4 41 70 101 33 114 110 58 67 24 81 80 44 32 74

The following are some examples of the original with encrypted text. In these examples, encrypted text follows the original one.

  1. Plain text:

    Biology is a natural science concerned with the study of life and living organisms, including their structure, function, growth, evolution, distribution, identification and taxonomy.[1] Modern biology is a vast and eclectic field, composed of many branches and subdisciplines. However, despite the broad scope of biology, there are certain general and unifying concepts within it that govern all study and research, consolidating it into single, coherent field.

    Cypher text:

    75 102 3 0 62 102 67 102 53 88 44 100 1 95 97 37 80 60 108 26 32 119 58 120 29 26 10 83 32 5 10 8 77 113 42 95 119 30 112 11 57 121 60 19 62 11 52 5 17 101 69 38 11 42 68 101 29 65 46 31 103 115 86 65 112 127 30 105 62 80 88 105 62 115 64 101 5 44 120 6 0 81 14 87 116 122 63 104 33 75 83 11 54 64 18 91 124 110 33 51 84 109 25 103 18 114 23 79 13 43 125 114 20 13 103 92 18 113 56 31 34 108 20 48 49 38 48 70 118 105 50 72 101 111 111 20 117 61 76 30 58 59 109 19 17 28 23 3 3 60 26 116 58 38 104 109 12 51 68 5 82 27 71 101 58 118 32 79 1 67 100 96 63 48 96 39 94 53 46 83 16 82 72 13 90 113 48 47 13 50 18 99 58 82 34 106 102 113 34 28 34 3 11 89 47 115 15 64 2 100 15 82 81 56 7 116 79 13 13 100 119 92 90 22 109 6 55 63 85 112 91 77 65 60 81 22 22 105 4 103 12 0 124 119 95 83 51 57 100 67 75 69 38 60 23 124 74 12 98 88 45 119 114 87 60 93 30 108 14 68 95 73 120 122 50 17 17 62 39 38 51 108 86 59 29 33 32 31 41 40 2 46 19 47 18 9 44 97 43 3 96 39 114 20 50 67 58 92 120 48 27 11 51 123 124 20 101 81 124 97 107 85 69 30 73 26 8 78 74 99 63 76 69 90 15 57 104 91 90 4 106 33 86 43 57 105 50 70 46 96 89 36 84 5 6 64 40 57 97 117 6 35 69 123 14 48 94 95 93 13 117 64 39 25 120 55 37 102 98 35 9 126 15 94 79 60 29 61 34 9 103 61 57 127 4 95 102 97 74 53 121 111 53 106 121 90 97 36 95 15 84 123 41 86 19 21 112 44 36 56 69 94 6 0 91 113 29 94 41 72 84 12 29 125 82 109 67 103 96 28 53 88 126 126 56 28 64 97 80 120 34 91 62 127 61 46 85 13 22 80 16
    
  2. Plain text:

    Iron man

    Cypher Text:

     59 32 3 20 48 32 56 127
    

I tried to solve the above encryption, but couldn't get any solution. Is it possible to solve this one, and how can one do that?

Given below is the encryption used for encryption. The following code is written in Python.

#For making a list for letters
letters=[]
for i in range(0,128):
    letters.append(chr(i))
index=list(range(128))
num=dict(zip(letters,index))
char=dict(zip(index,letters))
#Making rotors
ref=[110, 94, 63, 82, 56, 101, 108, 78, 5, 12, 24, 79, 52, 6, 0, 84, 74, 65, 50, 18, 67, 85, 30, 44, 120, 7, 113, 26, 83, 126, 96, 71, 97, 19, 73, 100, 45, 54, 17, 121, 49, 43, 125, 35, 64, 123, 104, 2, 115, 111, 98, 107, 119, 88, 14, 36, 15, 60, 69, 70, 80, 32, 46, 103, 40, 118, 109, 105, 25, 13, 41, 76, 33, 11, 31, 51, 77, 9, 8, 99, 114, 27, 55, 102, 92, 90, 10, 42, 29, 116, 117, 62, 28, 22, 21, 87, 47, 58, 3, 66, 124, 20, 122, 57, 127, 95, 112, 81, 23, 34, 89, 1, 4, 48, 91, 75, 72, 93, 86, 106, 16, 37, 59, 61, 53, 68, 38, 39]#reference for making the rotors
rotorin=list(range(0,128))
rotor1,rotor2,rotor3={},{},{}
rotor=[rotor1,rotor2,rotor3]
#Making and setting the rotor position. i from 0 to 2 and p from 0 to 255.
def setrotorposition(i,p):#setting the ith rotor position to p.
    out=[]
    for k in range(0,128):
        out.append(p)
        p+=1
        if p==128:
            p=0
    rotor[i]=dict(zip(ref,out))
def setrotorpositiond(i,p):#setting the ith rotor position to p.
    out=[]
    for k in range(0,128):
        out.append(p)
        p+=1
        if p==128:
            p=0
    rotor[i]=dict(zip(out,ref))
def encrypt(text,key):
    etext=open('etext.txt','w')
    setrotorposition(0,key[0])
    setrotorposition(1,key[1])
    setrotorposition(2,key[2])
    a0,a1,a2=key
    rp=[a0,a1,a2]#rp-rotor position
    letter=list(text)
    for k in range(len(letter)):
        letter[k]=str(rotor[2][rotor[1][rotor[0][num[letter[k]]]]])
        if rp[0]!=127:
            rp[0]+=1
            setrotorposition(0,rp[0])
        elif rp[1]!=127:
            rp[1]+=1
            rp[0]=0
            setrotorposition(0,rp[0])
            setrotorposition(1,rp[1])
        elif rp[2]!=127:
            rp[2]+=1
            rp[0],rp[1]=0,0
            for i in range(3):
                setrotorposition(i,rp[i])
        else:
            rp[0],rp[1],rp[2]=0,0,0
            for i in range(3):
                setrotorposition(i,rp[i])
    etext.write(' '.join(letter))
    etext.close()
def decrypt(efile,key):
    etext=open(efile,'r')
    dtext=open('dtext.txt','w')
    setrotorpositiond(0,key[0])
    setrotorpositiond(1,key[1])
    setrotorpositiond(2,key[2])
    rp=key
    letter=(etext.read()).split(' ')
    for k in range(len(letter)):
        if letter[k]!=' ':
            decrypttext=char[rotor[0][rotor[1][rotor[2][int(letter[k])]]]]
            dtext.write(decrypttext)
            if rp[0]!=127:
                rp[0]+=1
                setrotorpositiond(0,rp[0])
            elif rp[1]!=127:
                rp[1]+=1
                rp[0]=0
                setrotorpositiond(0,rp[0])
                setrotorpositiond(1,rp[1])
            elif rp[2]!=127:
                rp[2]+=1
                rp[0],rp[1]=0,0
                for i in range(3):
                    setrotorpositiond(i,rp[i])
            else:
                rp[0],rp[1],rp[2]=0,0,0
                for i in range(3):
                    setrotorpositiond(i,rp[i])
    etext.close()
    dtext.close()
techraf
  • 9,141
  • 11
  • 44
  • 62
lattitude
  • 131
  • 1
  • 3
  • Wish I had time to work on this one...! You may want to look at similar patterns in the ciphertext. For example, "ABCAA" and "XYZXX". Off the top of my head, these are called isomorphs. – S.L. Barth Jun 22 '16 at 11:53
  • Are these messages encrypted with the same key? I've looked for isomorphs and my impression is that they were encrypted using different keys. – S.L. Barth Jun 22 '16 at 19:26
  • This actually seems more like it'd belong on the crypto stack exchange – Robert Mennell Jun 22 '16 at 21:57
  • This kind of "break my homebrew crypto" is explicitly off-topic on crypto.se. – CodesInChaos Jun 23 '16 at 08:07

2 Answers2

2

The plain text of first ciphertext is:

Encryption is the most effective way to achieve data security. To read an encrypted file, you must have access to a secret key or password that enables you to decrypt it. Unencrypted data is called plain text ; encrypted data is referred to as cipher text.

I was able to break this with a simple brute force because the keyspace is small (128^3), and can be searched in less than 1/10 of a second even on modest commodity hardware.

The key was 100 2 3.

Anders
  • 64,406
  • 24
  • 178
  • 215
A Heisner
  • 31
  • 3
2

Yes, this can be broken, but no, I'm not going to do it.

Your friend's system is based on the principles of Hebern rotors. Such schemes were first broken in the 1920s. The most famous break of these was the Bombe, used to crack the German Enigma codes in WW II. The Enigma was a three-rotor system and looks quite similar to this algorithm, the principle obvious differences being the lack of a stecker and reflector, and this algorithm uses the same wiring pattern for each rotor (the Enigma had a set of differently wired rotors that the operator had to select and install in the correct order as part of the key to decrypt messages.)

Today, the entire class of rotor cyphers can be broken by digital computers using nothing more than simple brute force. See "Breaking German Army Ciphers" by Geoff Sullivan and Frode Weierud for some modern research. I believe there is lots of published source code for "Enigma crackers" on line that you can search for if you're looking for examples of ways to attack this yourself.

John Deters
  • 33,650
  • 3
  • 57
  • 110
  • But, what if he also changed that ref list used at the beginning of the programme? That is we didn't know what that ref list is. Can this be broken even without knowing that list?? – lattitude Jun 23 '16 at 03:07