Secure or not secure? Part I
Part II can be found here.
If you use an encryption process that makes a brute-force attack infeasible, is that encryption method secure ? What do you think ? Let’s use a simple and historical method called the “mono-alphabetic substitution cipher” ? Sounds scary, right ? In the end it’s very simple ๐
Supposed we have the readable message “this is a super secure message”. So far so good. Now we gonna encrypt that message with “mono-alphabetic substitution cipher”. We simply assign a new letter to each letter in the alphabet. For example, we make an A into an X and a D into an A. Our translation table looks like follow:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
X E U A D N B K V M R O C Q F S Y H W G L Z I J P T
With that table we can encrypt our message.
The message “this is a super secure message” is encrypted to “GKVW VW X WLSDH WDULHD CDWWXBD“. But is these secret message really secure ? Hm, let’s calc what attempts we need to brute-force this encrypted message.
Here is my python script for encryption:
mono_alphabet_dict = {
'A':'X',
'B':'E',
'C':'U',
'D':'A',
'E':'D',
'F':'N',
'G':'B',
'H':'K',
'I':'V',
'J':'M',
'K':'R',
'L':'O',
'M':'C',
'N':'Q',
'O':'F',
'P':'S',
'Q':'Y',
'R':'H',
'S':'W',
'T':'G',
'U':'L',
'V':'Z',
'W':'I',
'X':'J',
'Y':'P',
'Z':'T',
}
original_message = "this is a super secure message"
encrypted_message = ""
for char in original_message:
# check for all letters in the alphabet. special letters like '|&%ยง!ยง' are not being encrypted
if ord(char) == 32:
encrypted_message += " "
if (ord(char) >= 65 and ord(char) <= 90) or (ord(char) >= 97 and ord(char) <= 122):
encrypted_message += mono_alphabet_dict[char.upper()]
print(encrypted_message)
And here the script for decryption:
mono_alphabet_dict = {
'X':'A',
'E':'B',
'U':'C',
'A':'D',
'D':'E',
'N':'F',
'B':'G',
'K':'H',
'V':'I',
'M':'J',
'R':'K',
'O':'L',
'C':'M',
'Q':'N',
'F':'O',
'S':'P',
'Y':'Q',
'H':'R',
'W':'S',
'G':'T',
'L':'U',
'Z':'V',
'I':'W',
'J':'X',
'P':'Y',
'T':'Z',
}
original_message = "GKVW VW X WLSDH WDULHD CDWWXBD"
decrypted_message = ""
for char in original_message:
if ord(char) == 32:
decrypted_message += " "
# check for all letters in the alphabet. special letters like '|&%ยง!ยง' are not being decrypted
if (ord(char) >= 65 and ord(char) <= 90) or (ord(char) >= 97 and ord(char) <= 122):
decrypted_message += mono_alphabet_dict[char.upper()]
print(decrypted_message)
Some facts:
– We have used the english alphabet with 26 letters
– The length of our key is 26
With that in mind we can simply calculated all possible combination which is 2^88 (26*25*24*….1). A big damn number and an incredible number of possibilities. So brute-force is not really an option here. But is our message really safe and secret?
What do you think ? Can we reveal the secret ? We’ll see that in next post.
Cheers
1 Comment