::: success # SSN Lab № 1 Assignment: Classical Crypto **Name: Khasan Abdurakhmanov** ::: <center> ## Task 1 </center> 1. ##### Go to https://www.dcode.fr/tools-list#cryptography or https://cryptii.com/ crypto service website. Choose Vigenere ciphers and get familiar with it. First of all I consider all these two websites. <center> ![](https://hackmd.io/_uploads/Bkp4kwJR2.png) Figure 1: It's how the cryptii.com website looks </center> And also I noticed that here is the library of any kind of ciphers <center> ![](https://hackmd.io/_uploads/BkSrMvJR3.png) Figure 2: Different types of ciphers </center> Here we can see the another alternative for cryptii.com website. It's dcode.fr <center> ![](https://hackmd.io/_uploads/H1J-HDJRh.png) Figure 3: The website interface of dCode.fr </center> dCode.fr also provides us with various items: <center> ![](https://hackmd.io/_uploads/Hydqdw1Ch.png) Figure 4: Various items of dCode.fr </center> ### Vigenere cipher In a Vigenère cipher, a keyword is used to determine the shift value for each letter of the message. The first letter of the keyword is used to determine the shift value for the first letter of the message, the second letter of the keyword is used for the second letter of the message, and so on. When the end of the keyword is reached, the process starts from the beginning of the keyword. Using this method, the Vigenère cipher allows for a much more complex encryption scheme than the standard Caesar cipher. However, it can still be decrypted if the keyword is known. 2. ##### Make a team of two, encrypt an English text of at least 50 words using the Vigenere cipher, and exchange it with your fellow student. My friend and fellow course mate Saad kept me company for this task. Firstly I translated this message "Y**ou won't be able to read this. It will never ever happened))).**" into cipher via cryptii.com. Afterwards I get this ciphertext "**Afs lhv'b dv yqem bq icpw bpkj. Gi pqtn eckxz mxvp wtxxgecs))).**" <center> ![](https://hackmd.io/_uploads/r1l7FOkCh.png) Figure 5: Encryption process </center> And after that Saad sent me his ciphertext "**Becevolloy ip qneubriziblv qntbztwfved tqth zwmmrvicxbiok, jut eww dl ee kkww ic inylve ip zeaity lfatekqng? Emre fa a sqwry xjouq perlqsm, qzusq, ind x derv tond latx atrbim teit dlkumbvts qpe upm of qmchkwlodg as bapilvagb.**". <center> ![](https://hackmd.io/_uploads/Skiyqd1R3.png) Figure 6: Getting the ciphertext </center> 3. ##### Crack the encrypted text of your fellow student using the Vigenere cipher tool. Using the Vigenere Decoder tool to crack and decipher this message was clearly the most obvious choice for me. <center> ![](https://hackmd.io/_uploads/rJVAsuJAn.png) Figure 7: Process of cracking the ciphertext </center> Here I used automatic decryption and get more than 100 variants of decrypted text and I found out what did Saad want to send me. The plaintext was "**Technology is inextricably intertwined with communication, but how do we know if anyone is really listening? Here is a story about heroism, trust, and a very long data stream that documents the use of technology as espionage.**" 4. ##### Go through the previous two steps again, this time using a cipher of your own choosing. Do not tell your fellow student what cipher you used! I have employed the identical plaintext but have altered the encryption method.I chose Morse code. > Morse code is a communication system that uses a series of dots and dashes to represent letters, numbers, and symbols. It was developed by Samuel F.B. Morse in the early 1800s, and was first used in telegraphy. Morse code is based on the idea of encoding the alphabet and numbers into shorter signals: dots and dashes. Each letter of the alphabet, and each number, has its own unique configuration of dots and dashes. <center> ![](https://hackmd.io/_uploads/Bk19MY1Rn.png) Figure 8: Morse ciphertext </center> I translated this plaintext "**You won't be able to read this. It will never ever happened))).**" into ciphertext "**-.-- --- ..- / .-- --- -. .----. - / -... . / .- -... .-.. . / - --- / .-. . .- -.. / - .... .. ... .-.-.- / .. - / .-- .. .-.. .-.. / -. . ...- . .-. / . ...- . .-. / .... .- .--. .--. . -. . -.. -.--.- -.--.- -.--.- .-.-.-**" And sent it to my friend Saad. He replied me with this message "**Yuzwmybsoz sa a hflo mv bjkow vnxmpisfu a bmglgkwb mj d yeoljhoj nzhwmjt. Hlw ypodghzj gac waxw zzwf gizx kn ypogshksfu hww qjsrw, ej sk osc zz hlw hdjmwh. Bcrwjbjkow rau tamo amozmfw'i lwqgjvhu mj ysfanbwa.**" It was a task which I should solve. I needed to decrypt it but how? First of all I thought about frequency analysis of letters in English that we discussed in lectures. <center> ![](https://hackmd.io/_uploads/H1P5rtk0n.png) Figure 9: frequency analysis of letters in English. </center> And I did the same analysis for my ciphertext |Letter|Count| | a | 1 | | b | 3 | | c | 0 | | d | 2 | | e | 0 | | f | 1 | | g | 2 | | h | 5 | | i | 0 | | j | 2 | | k | 3 | | l | 1 | | m | 1 | | n | 1 | | o | 2 | | p | 1 | | q | 1 | | r | 0 | | s | 2 | | t | 0 | | u | 1 | | v | 1 | | w | 3 | | x | 0 | | y | 1 | | z | 2 | In my case, frequency analysis did not help. I tried replacing frequently occurring letters in the ciphertext with the most frequently used letters in the English language, but unfortunately it didn't help me. I thought it was another type of cipher, a bit like the Vigenere cipher. > Beaufort encryption is a type of encryption based on a substitution cipher. It is similar to the Vigenère cipher, but with the key and plaintext being reversed. The key is used to encrypt the plaintext, and the encrypted text is used to decrypt the plaintext. The encryption is done by shifting each letter in the plaintext by a number of positions equal to the corresponding letter in the key. The decryption is done by shifting each letter in the encrypted text by a number of positions equal to the corresponding letter in the key. Then I went to the dCode.fr website and wanted to see if I was right. The cipher identifier showed me, first of all, the Vigenere cipher, but we realized that this was not the right cipher, frequent analysis helped us to make sure of that. <center> ![](https://hackmd.io/_uploads/ByUyx_gA3.png) Figure 10: Cipher Identifier </center> In second place was the Beaufort cipher. It was just what we needed. After that, I started trying to crack this cipher. The important thing in these polyalphabetic ciphers, if you don't have the key, is to try to use the Kasiski method and guess the length of the key. > The Kasiski examination, also known as the Kasiski test, is a method used to determine the length of the key used in a Vigenère cipher. It involves searching for repeated sequences of letters in the ciphertext, which can reveal information about the key. By analyzing the distances between the repeated sequences, it is possible to estimate the length of the key. The Kasiski method is named after Friedrich Kasiski, a 19th century German cryptographer who first described the technique. I did a Kasiski test and was surprised in a ciphertext there were more than 2 repetead seqecnces like mj,hlw. <center> ![](https://hackmd.io/_uploads/Bk507OxRh.png) ![](https://hackmd.io/_uploads/HJhJ4_e03.png) Figure 11: Kasiski text </center> After this kind of calculations I found the length of the key, and it turned out to be equal to 5. After that it was not difficult to get the source text. I started moving each letter of the ciphertext by 5 positions in alphabetical order. The first letter was "Y", if I move it 5 positions in alphabetical order, I will get the letter "C", and so on for each letter of the ciphertext. In the end, I got the original text "**Cybercrime is a type of crime involving a computer or a computer network. The computer may have been used in committing the crime, or it may be the target. Cybercrime may harm someone's security or finances.**". After that, I decided to test it with a tool on the dCode.fr website. <center> ![](https://hackmd.io/_uploads/r16cSOx03.png) Figure 12: Beaufort Cipher Decoder </center> And the plaintext was the same. And I found out that the key was his name "ASAAD" :). <center> ## TASK 2 </center> 1. ##### Read about the Enigma machine, how and why it was used? The Enigma machine was an electro-mechanical rotor cipher machine used by the German military during World War II. It was designed to encrypt and decrypt secret messages. The Enigma machine used a combination of rotors, plugboards and reflectors to create an encryption algorithm that could be used to encode and decode messages. The Enigma machine was essentially a code-making and code-breaking device and was incredibly difficult to crack. It was used extensively by the German military to transmit top secret messages and was a major factor in the war effort. > The system worked by changing the rotor settings regularly, making it incredibly difficult to break the code. In fact, during the early years of the war, the Enigma code was considered unbreakable, and the Germans were confident that their messages were completely secure. However, codebreakers at Bletchley Park in the UK eventually managed to break the code, using a combination of mathematical analysis and innovative computing techniques. 2. ##### Explain the mechanism of its encryption/decryption. The Enigma machine used a combination of rotors, plug boards, and reflectors to create a robust algorithm for encoding and decoding messages. When a user typed a message into the machine's keyboard, an electric current passed through a series of rotors that encoded the message into an unintelligible sequence of letters. The encrypted message then passed through a plug-in that further distorted the letters, before passing through a reflector and back to the machine's rotors. The result was an encrypted message that could only be decrypted by a machine with the same rotor settings. To decrypt a message, the receiver would need to know the exact rotor settings used to encrypt the message. They would input the encrypted message into the machine and, assuming they had the correct rotor settings, the machine would reverse the encryption process and output the original plaintext message. However, due to the complexity of the machine and the regular changing of rotor settings, decrypting Enigma-encoded messages was a very difficult task that required significant feats of mathematical analysis and computing power. 5. ##### Come with some creative text and encipher/ decipher with Enigma encryption I went to the cryptii.com and used Enigma cipher to encrypt this text "Anything is possible, the impossible just takes more time." <center> ![](https://hackmd.io/_uploads/By3DAuxAn.png) Figure 13: Encrypting via Enigma Cipher </center> And got this ciphertext "**xpxxx nqwqr ufflr inayi ovouc bpaka oienl afcwk sdcug soo**". and then I did vice versa. <center> ![](https://hackmd.io/_uploads/rknyJFeC2.png) Figure 14: Decrypting via Enigma Cipher </center> I got the plaintext "**anyth ingis possi bleth eimpo ssibl ejust takes moret ime**".