Cryptology, cryptography and cryptanalysis
Let's jump into the theoretical knowledge you'll need when writing the final project. Let's learn more about cryptography and its constituent parts. And at the same time, we'll learn more about the cipher that you will use when writing the final project.
1. Cryptology and its constituent parts
Cryptology is a field of knowledge that includes:
Cryptography (the science of ciphers).
Cryptography is all about encrypting information to protect it from unauthorized access. This information could be text, a digital image, an audio signal, etc. The encryption process produces an encrypted version of the information (data), which is called the ciphertext or codetext.
Cryptanalysis (methods for cracking these ciphers).
Cryptanalysis examines methods of breaking ciphers and how these methods can be applied. In other words, cryptanalysis performs the inverse task, studying ways to turn encrypted information into plaintext.
2. Cryptographic key
A key is a selection of data that is used to encrypt and decrypt information. The ability to successfully decrypt information depends on what key is used. If a key is lost for some reason, then it will be impossible to decrypt the data.
The size of cryptographic keys is measured in bits. And this means that a cryptographic key has a length. Good encryption strength is provided with a length of 128 bits.
Types of cryptographic keys:
Symmetric keys (secret keys). Unsurprisingly, such keys are used in what are known as symmetric-key algorithms. Their main purpose is to perform forward or reverse cryptographic transformations (encryption/decryption, verification of the message authentication code).
Asymmetric keys. They are used in asymmetric-key encryption algorithms (for example, when verifying an electronic digital signature).
Since we'll be working with a symmetric-key encryption algorithm, we won't go into too much detail here.
3. Substitution alphabet
A substitution alphabet is a complete set of characters used to encode input characters.
4. Approaches to cryptanalysis
There are many different cryptanalysis approaches and methods, i.e. ways to crack ciphers.
We'll describe the simplest of them:
Brute force (or brute force search) is trying all possible keys until we find the correct one. The advantage of this method is its simplicity. The disadvantage is that it is not suitable for ciphers involving a large number of possible keys.
Cryptanalysis based on statistical data — in this approach, we gather statistics on the occurrence of different characters in the ciphertext, and then we decrypt based on statistics on the frequency of occurrence of different characters in plaintext.
For example: we know that the frequency of the letter P in English texts is 1.9%. As we analyze the ciphertext, we look for a symbol that occurs with the same frequency and then conclude that it is the letter P.
The disadvantage of this approach is its dependence on the specific language, author, and style of the text.
5. Caesar cipher
This is one of the simplest and most well-known encryption methods. Its name, of course, comes from the Emperor Gaius Julius Caesar, who used this method to correspond secretly with generals.
A Caesar cipher is a substitution cipher in which each character in the plaintext is replaced by a character that is some constant number of positions to its left or right in the alphabet.
Let's say we set the shift to 3. In this case, A will be replaced by D, B will become E, and so on.
This is the minimum amount of theory you will need to complete the final project. Let's move on to the task description!
Final project for the Java Syntax module. Let's write a cryptanalyzer
Your task is to write a program that works with Caesar ciphers.
Let your cryptographic alphabet consist of all the letters of the English alphabet as well as punctuation marks (. , ”” : - ! ? SPACE). If you encounter characters that are not part of our substitution alphabet, then just skip them.
The program should have 2 modes:
Encryption/decryption. The program must encrypt and decrypt text using a given cryptographic key.
The program should receive a path to a text file containing source text and create a file containing the corresponding ciphertext.
Cryptanalysis by brute force attack
In this mode, the program must crack the ciphertext contained in an input text file.
If the user selects brute force, then the program must independently enumerate the possible keys, select the correct key, and decrypt the text.
Think about what criteria the program should use to successfully identify the correct key. You may need to pay attention to the spaces between words or the correct use of punctuation marks.
Additional (optional) requirements
1. Cryptanalysis by statistical analysis
The user should be able to choose one of two cryptanalysis methods. If the user selects statistical analysis mode, then prompt the user to load an additional text file in plaintext, preferably by the same author and in the same style. Based on the contents of the second file, the program should compile statistics on the occurrence of characters and then try to use these statistics to perform cryptanalysis of the ciphertext.
2. User interface
Make dialog boxes for interaction with the user at your discretion. If desired, you can use the Swing and JavaFX graphic frameworks.
Upload your finished solution to a public Git repository.
The project will be checked when the group goes through it