System: You are ChatGPT, a large language model trained by OpenAI.
User: I will send you a body of text, I will then state what you do next.
User: 220 27 EncryptionINTRODUCTION Encryption  is the process of scrambling data so that it cannot be underst ood by another person unless they know the encryption method and key used. Decryption  is the process of turning the scrambled data back into data that can be understood. Data is encrypted before it is  transmitted and decrypted when it is received. Therefore encryption keeps data secure during transmission. DataSENDER RECEIVER UNAUTHORISED ACCESSFigure 27.1 Unauthorised interception of dataSPECIFICATION COVERAGE 3.5.6.8 Encryption in AS Level3.5.6.10 Encryption in A Level LEARNING OBJECTIVES In this chapter you will learn: •what encryption is and why it is important•the basics of encryption techniques •how to encrypt a message using the Caesar cipher•how to encrypt a message using a transposition cipher •how to encrypt a message using the Vernam cipher•how to use frequency analysis to help decrypt ciphers •what computational security is.
 KEYWORDSEncryption: the process of turning plaintext into scrambled ciphertext, which can only be understood if it is decrypted. Decryption: the process of decipher ing encrypted data or messages.ENCRYPTION BASICS 221Data are vulnerable when they are accessed by a third party who should not have access to them. This might occur if someone gains access to saved files on a computer, or when data are transmitted across networks. Often the nature of the data being sent is personal or sensitive and there is a risk if someone were to intercept them. For example: ●online banking transactions need to be kept secure to prevent theft andfraud ●health information needs to be kept secure as it contains very sensitivepersonal information ●government security data needs to be kept secure as they could haveimp lications for national security.In fact the use of encryption is closely linked to matters of government and military security as many techniques were developed and used during conflicts. With the widespread use of the Internet over recent years, encryption has become a vital mechanism for securing data sent across local and wide area networks. ●Encryption basics All encryption works on the basis of turning plaintext  into ciphertext  ashown in Figure 27.2. The message is writtenin ‘plaintext’“BROADSWORD CALLING DANNY BOY”SENDER “DTQCFUYQTF ECNNKPIFCPPA DQA”“BROADSWORD CALLING DANNY BOY” RECEIVERThe message is encryptedinto ‘ciphertext’ usingan algorithm The message is sent The message is receivedThe message is decrypted back into ‘plaintext’ asreceiver knows how the algorithm encrypted the dataFigure 27.2 The encryption–decryption process Plaintext is the original data in a format that can be understood. The data are then encrypted or encoded using an algorithm that turns the data into ciphertext. The message can then be sent. Encryption does not prevent the data from being intercepted, it just makes them meaningless to the person who intercepted them unless they know how the data have been encrypted.It is common practice therefore for people to try and work out what algorithm has been used, that is, to try and crack the code. There are many famous examples of code-breakers throughout history, not least the work done on the German Enigma machine during WWII by both Polish and British mathematicians. Many people believe that their ability to crack this code KEYWORDS Plaintext: data in human-reada ble form.
 Ciphertext: data that has been encrypt ed.27 Encryption222enabled the Allies to win the war as they were able to intercept and read messages about the German war effort. There are various techniques for encrypting data and in this chapter we will be considering two of the common ones: the Caesar cipher  and the Vernam cipher . We will also be considering transposition ciphers . A-level students also need to be aware of public and private key encryption and this is covered in Chapter 44.A key  is a piece of data used in encryption that defines the way in which  plaintext is turned into ciphertext. You will see some examples in this chapter. The key that is used by the sender to encrypt the message must be known by the receiver so that they can decrypt the message. Some keys, like those used with a Caesar cipher are too easy to work out, whereas other keys like those used on a Vernam cipher are theoretically impossible to crack. ●The Caesar cipherNamed after the Roman Emperor who used it for all of his personalcorrespondence, the Caesar cipher is an example of a shift or substitution cipher . This method substitutes each letter of the alphabet for anotherchar acter by simply shifting the letters forwards or backwards. A variationon this would be to shift letters on a random basis.
 The diagram below shows a substitution cipher with a two-letter shift.In this case, the message: “BROADSWORD CALLING DANNY BOY”becomes “DTQCFVYQTF ECNNJPI FCPPA DQA”. AB ABCDEFGHIJKLMNOPQRSTUVWXYZA random substitution might look like this: AB UHCDEFGHIJKLMNOPQRSTUVWXYZOZPCYDBQXKLAVWRISMJEGNFT Our message when encrypted with this random substitution becomes: “ZMROCJFRMC POAAXWB COWWU ZAU”.
 Both of these methods would be fairly easy to work out, even without the key. It could be made more secure by adding a keyword, for example, you might select the word “BEESWAX”. First, you need to delete any repeated letters in the word, leaving you with “BESWAX”. Then add this word to the start of the alphabet. In other words, the first seven letters of the alphabet are substituted for the keyword. Then add the remaining letters in alphabetical order: ABCDEFGHIJKLMNOPQRSTUVWXYZBESWAXCDFGHIJKLMNOPQRTUVYZ The message can then be encrypted. With any of these three examples, the receiver would need to know what key is being used. If it is a two-letter shift then they only need to shift +2 to decrypt the message. If a keyword is being used then they need to know the keyword. In the case of the random substitution they would need the entire look-up table. Therefore to KEYWORDSCaesar cipher: a substitution cipher where one character of plaintext is substituted for another, which becomes the ciphertext. Vernam cipher: a method of encryption that uses a one-time pad (key) to create ciphertext that is mathematically impossible to decrypt without the key.
 Transposition cipher: a method of encryption  where the characters are rearranged to form an anagram. Key: in cryptography it is the data that is used to encrypt and decrypt the data.
 Substitution cipher: a method of encryption where one character is substituted for another to create ciphertext.FREQUENCY ANALYSIS223decipher the code, the recipient would need the key, which in this case is the keyword, and the encryption method.A further level of complexity can be added to a substitution cipher with the  use of more than one alphabet. This is known as a polyalphabetic  cipher and ra ther than having one set of substitutions it could have any number of alphabets or look-up tables to work with. For example, there might be ten different versions of the look-up table above. Each letter that is encrypted is passed through all of them to produce a final encrypted letter. For example, using four different alphabets an example might look like this: ●The letter ‘A’ is encrypted using the first alphabet to the letter ‘W’●The letter ‘W’ is encrypted using the second alphabet to the letter ‘S’ ●The letter ‘S’ is encrypted using the third alphabet to the letter ‘P’●The letter ‘P’ is encrypted using the fourth alphabet to the letter ‘D’. The letter “D” is then used in the encrypted message. All four alphabets will be needed to decrypt the message.
 This concept goes back to the 15th century and is known as the Alberti cipher. This is also one of the underlying principles used in the Enigma machine, where several randomised alphabets were used to encrypt a message. ●Frequency analysisThe Caesar cipher is one of the easiest to crack because of the nature oflanguage. In English, for example, there are certain letters that are usedmore frequently than others and certain combinations of letters that arealso common. By examining ciphertext for frequently used letters andpatterns of letters it is possible to work out what letter has been substitutedfor which other letter. For example, a frequency analysis of letters used in most English writingmight look like Figure 27.3. a00.020.040.060.080.10.12Relative frequency0.14 bcdefghi jkLetterlm nopqrs tuvwxyz Figure 27.3 Frequency analysis of letter usageKEYWORDPolyalphabetic: using more than one alphabet.
 KEYWORD Frequency analysis: in crypt ography it is the study of how often different letters or phrases are used.
 Notice that ‘e’ is the most frequently used letter followed by ‘t’. ‘j’ and ‘x’ are used infrequently. If you took a large block of ciphertext and carried out the 27 Encryption 224same analysis you would find a pattern. For example, if the ‘e’ was replaced by a ‘p’, then ‘p’ would be the most frequently used letter in the ciphertext and you can therefore assume that e = p. You could do this for all of the other letters by matching their frequencies.In modern computing, cryptography like this could be cracked instantly, so more sophisticated methods have been developed.
 ●Transposition cipher With this type of cipher, the letters of the message are transposed, or rearrangedto form an anagram. You must rearrange the letters according to a set patternto make it possible to decrypt the message. One way of doing this is called therailfence  method where the message is split across several lines. For example: B O D W R C L I GR A S O D A L N If you now read the message off line by line it becomes: “BODWRCLIGRASODALN”. If you were decrypting this message you would need to know that the key is that it has been split over two lines.
 To decrypt it, you simply read it back by moving down and then up. You  could use any combination of lines and line lengths. For example, you could put the message across three lines: O W C IB D R L GR A S O D A L N In this case, the message becomes: “BDRLGRASODALNOWCI”.
 A variation is to put the message into a grid. This is called a route  cipher . For example, the same message is placed into a 6 × 3 grid.
 Reading down in columns from left to right will decrypt the  message. Notice that you can add null or meaningless values if you have spare cells in your grid. In this case, the letter ‘A’ has been added to the bottom right-hand cell.As with Caesar ciphers, complexity can be added to the key with the addition of a keyword before the main message. It is also common practice to combine then apply a substitution cipher to the transposed message so that there are two codes to crack to decipher the original message as shown in Figure 27.4.
 Message BROADSWORDCALLINGTransposition cipher Message sent6 × 3 grid “HEISENBERG”Substitution cipher using keyword BWLROLORIADNDCGSAA EWFPLFLPASKSIRQHHFigure 27.4 A substitution cipherBR OA DSW OR DC AL IN GA Although more complex than a straight transposition cipher, it is still possible to decrypt this message without knowing the key using a combination of frequency analysis and anagram deciphering. KEYWORDSRailfence cipher: a type of transposition cipher that encodes the message by splitting it over rows. Route cipher: a type of transposi tion cipher that encodes the message by placing it into a grid.VERNAM CIPHER225●Vernam cipher Gilbert Vernam invented this cipher around 100 years ago as a means ofkeeping data secure whilst it was being transmitted using telex machines.The Vernam cipher is an example of a class of encryption techniquesknown as one-time pad techniques. The key that is used is a sequence ofletters t hat should be as long as the plaintext that is being encoded. The keycan be recorded on a pad, although in the Vernam case the key was writtenon a punched taped for input into the telex device. For maximum security,a particular key should only be used to encrypt one message, hence thename one-time pad.To encrypt a message, each character in the plaintext is combined with the character at the corresponding position in the key by convertingthe corresponding plaintext and key characters into a binary code(originally a 5-bit Baudot code ) and using a logical XOR on these binary representations to produce a new binary code, which in turn maps back toa character. Once the ciphertext is created the key is never used again forencryption, although it will be used once more to decrypt the ciphertext. A message is encrypted and decrypted as follows: ●The key is created, which is a completely random sequence of characters. For example, each letter in the plaintext message “BROADSWORD” is combined with the letter at the corresponding position in the key that iswritten on the pad or tape: B Plaintext message ROADSWORD H Key ELKKJVTUI ●For each character in the plaintext and the key, the 5-bit Baudotrepr esentation is identiﬁed. For example, B = 11001, H = 10100. A logicalXOR is then performed on the two values, which is a bitwise operationthat results in a 1 only if the two bits being compared are different. Inthis case: 1 Baudot code for plaintext B 1001 1 Baudot code for one-time pad H 01000 XOR the two codes to produce ciphertext 1101 ●The Baudot table is then used to find the corresponding character that is represented by 01101, which is F. Therefore the first characterin the ciphertext becomes F. This process is repeated for each letter inthe plaintext. ●On receipt of the ciphertext, assuming the receiver has access to the key,an X OR can be performed on the ciphertext with the key to find the original plaintext: 0 Baudot code for ciphertext F 11011 Baudot code for key H 0100 1 XOR the two codes to reproduce plaintext 1001 ●You can see that the result of the XOR operation is 11001, which isthe o riginal plaintext character of B. This process is repeated on everycharacter in the ciphertext.KEYWORDS One-time pad: a key that is only used once to encrypt and decrypt a message and is then discarded.
 Baudot code: a five-digit charac ter code that predates ASCII and Unicode.27 Encryption 226Nowadays, it is more likely that a character code such as ASCII or Unicode would be used to convert the characters to binary values instead of the Baudot code. Once the entire message has been encrypted and decrypted the key is destroyed and a new random key is created. As long as the key is completely random, and is kept secret and only used once, then it is mathematically impossible to crack the code. This is because the key is entirely random and therefore creates outcomes that are random. If you don’t know the key, then ciphertext letter A is just as likely to be plaintext H as it is L, or any other letter. Indeed, if the letter A occurred at more than one position in the ciphertext then it is likely that each occurrence of an A will correspond to a different letter in the plaintext. If someone intercepted the message, the best they could do is to try all possible keys to work out every possible plaintext, but there would be a huge number of these and no way to know which the correct one was. This is known as perfect security and it means that however much time and ciphertext a cryptographer has to work with, they will never be able to crack the code.In practice, complete security is more difficult to achieve as: ●generating completely random numbers is complex as any algorithm is likely to contain some element of predictability ●letting the receiver know what the key is (key exchange) is difficult asthis information itself could be intercepted ●there is no way of authenticating the sender and receiver so if the key was intercepted, messages could be sent from unauthorised sources. ●Computational securityThe Vernam or one-time pad cipher is the only cipher that is consideredto be 100% mathematically secure. All other ciphers can be cracked givenenough time and enough ciphertext to work on. This leads to the conceptof computational security or computational hardness . A cipher that is comp utationally secure is theoretically breakable but not when usingcurrent technology in a timeframe that would be useful. This recognises thefact that although most encryption can theoretically be cracked, in practiceit will be secure enough to withstand most threats. When devising encryption algorithms it means that programmers needto be aware that some levels of encryption are harder to crack than othersand that the level of security they use needs to be commensurate with thelevel of risk of the data being intercepted. For example, you would expecta much more sophisticated level of encryption on a data file being used tostore data on military movements than one used to store a school project.
 Computational security means that cryptographers need to be aware of the ways in which their encryption could be cracked. In addition to frequencyanalysis discussed earlier, there are several different methods for crackingcodes: ●Identifying commonly used techniques: Many ciphers are based onsubst itution or transposition. Experienced cryptographers are able torecognise patterns in data that has been encrypted using these methods.KEYWORDS Computational security: a concept of how s ecure data encryption is. Computational hardness: the degree  of difficulty in cracking a cipher.COMPUTATIONAL SECURITY 227●Reverse engineering: This is the process of going back step by step untilyou w ork out how something has been put together.O Dictionary attacks: This is the process of using a dictionary that contains  common words and phrases. After each attempt to decrypt text is made, the text can be compared to the dictionary to see if it matches. ●Brute force: This is similar to a dictionary attack but takes much longer asrat her than looking at common words and phrases it looks at every singlepermutation of characters that can be created and then compares thedecrypted text to these permutations. Practice questions can be found at the end of the section on page 228.
 TASKS1 What is encryption and why is it used?2 Explain the use of a key in encrypting and decrypting data. 3 Encrypt a message using: a)a simple shift cipher b)a simple substitution cipherc)a substitution cipher with a keyword.Yo u could do this on paper or create a programmed solution.
 4 What is a polyalphabetic substitution cipher?5 Why are substitution ciphers relatively easy to crack? 6 Encrypt a message using a transposition cipher. You could do this on  paper or create a programmed solution.7 Explain how the Vernam (one-time pad) cipher works with the aid of an  example. You could do this on paper or create a programmed solution.8 Why is the Vernam cipher said to be mathematically unbreakable?9 What conditions must be met for a Vernam cipher to be 100% secure? 10 How are most codes cracked?11 What is computational security? STUDY / RESEARCH TASKS1 Create a timeline of famous codes and ciphers that have been used throughout history. 2 Research the Enigma machine and ﬁnd out how messages sent using it were encoded and how the code was eventually cracked.3 There are many examples of ciphers and codes that have never been cracked. Find out about them. Why has no-one ever managed to decipher them?4 According to the government, as many as 80% of large business  experience security breaches every year. What are the implications for large organisations if their data is compromised?KEY POINTS•Data are vulnerable tointer ception whenever theyare being transmitted. •Encryption is the process ofscrambling data so that they can only be understood if theyare decrypted.
 •Decryption is the process ofturning encrypted data back into meaningful data.•A cipher is a code or keyappl ied to plaintext to turn itinto ciphertext. •There are three main typesof cipher you need to be aware of: Caesar, Vernam andtransposition.
 •As a programmer you needto be conscious of security issues relating to your ownprograms and data.
User: Make the following text more clear.
Format it properly.
Do NOT change the meaning of the words or methods used to obtain the answer or anything like that.
This is for AQA A(S)-Level Computer Science. I repeat, do not alter the words as it could have an affect on the marks acquired from the marking scheme.
However, remove any redundant information or USELESS examples that are not needed for a student to know, or simplify unnecessary information (if it has a definition or keywords, it is not unnecessary).
If you can, use different values for the examples.
For things that will not score a mark or are generally useless, for example, "we will cover" or a fun fact, change the wording.
Link the 'sections' of your answer to the following spec-points (by title):
e.g. "**Topic** (Spec Points: a.b.c. Whatever)
{spec_points_formatted}


You MUST make sure they are ALL met. Everything it says on there you should meet.

These are the available exam questions you MAY choose to add on to the notes, with 'des' explaining what it's about, and 'fil' meaning the Question ID.
{eq_list}

These are the content of said exam questions, delivered in form 'fil', JSON:

{questions}

If necessary for scoring marks, try to embed the exam-questions into your notes, sometimes without even referencing the fact that it is an exam question. For example, if an exam question is a definition or benefits, use the answer in your notes.
Remember. DO NOT ADD USELESS STUFF. Your task is to create the MOST EFFICIENT (SHORTEST [for an explanation] BUT STILL SCORES ALL MARKS) possible notes resource, which will score all marks easily, so its wording has to be mostly like that of the exam questions. By any means, if necessary, please include examples and exam questions! At the end you can have a 'try these exam questions' thing.

In summary, your answer must:

* Be efficient, useful
* For topics in an exam that may require some form of mathematical working, always show an example of a question.
* Be clear – provide clear, step-by-step examples/instructions when needed.
* Follow the entire specification and everything it says.
* Link your section to a spec point. E.g. **Topic** (Spec Points: a.b.c Whatever)
* Score ALL marks.
* Include exam questions at the end.
* Remove redundant, unnecessary and useless information that would not be brought up in an exam answer.
* Be helpful to the reader

At the end of the formatted text, after everything is done, fill out the JSON:
Remove the type clarification.
{
"chapter": (int),
"page": (int),
"chapter_name": (str),
"topics": (list)
}

Assistant: