If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

## Computer science theory

### Course: Computer science theory>Unit 2

Lesson 2: Ciphers

# Feedback

## What did you think of this lesson?

We hope you enjoyed this lesson. Please let us know what worked well and what could be improved in the discussion below. We will incorporate your feedback in future iterations.

## Want to join the conversation?

• What different kinds of logic gates are there?
• There is three types of gates: and gates, not gates, and or gates. If there is a "n" at the beginning of the name of a logic gate, then the output is the opposite of would it normally be. If there is a x at the beginning of the logic gate's name, then the output is flipped only if both inputs are a one. There is no xand gate because it would always output a 0. Similarly, there is no nxand gate because it would always output a 1.
• How would I create an encryption for a computer that prevents viruses?
• Short answer, you can't. Cryptography is the process of data obfuscation. Antivirus software is focused on identifying and eliminating viruses by signature or by behavior at the machine code level. They are two unrelated areas of study, and cryptography is not a generalized solution for every imaginable computer related problem. Cryptography does what cryptography does.
All modern commercially available microprocessors run, by definition, unencrypted machine code. So in order to run an encrypted piece of machine code, it would have to be decrypted first, and at that point it becomes vulnerable to attack, viral or otherwise. This a simple answer to a explain why a solution to a very old and very well understood problem still has not been solved.
• OR is inclusive
XOR is exclusive
A mnemonic for that is "ex"clusive sounds like the "x" in XOR.
That's how I remember the difference.
What are the ways you remember some of these techniques?
• What exactly is the point of using AND/OR/XOR as a cipher- I get the scrambling of pictures, but other than that where is it used?
• At most fundamental level, what you're trying to encrypt is a single bit of information (either a 1 or 0). Every message is converted into bits so that it can be used by a computer, so the question is: how can you encrypt a bit? The only way to do it is to apply a bitwise operation to it.
That's why we talk about the bitwise opperations AND/OR/XOR.
• The articles were at a good length by going over the topic really well while not being too information heavy. would've wanted more interactive activities.
• I'm only 13 so I'm only capable of understanding what cryptography is and simple ciphers/codes, but I still want to know what XOR is. Could someone explain it in simpler words? Many Thanks in Advance.
• XOR is a logic gate that takes (in encryption) a randomly binary sequence and on a one alters your original binary string, or doesn't on a 0. This is useful because it means, due to randomness, it changes the chance of a 0 to being COMPLETELY random. However, due to AND and OR having a 75% chance one way from a random string, this still allows only scrambling that seems about half as random, ie. half the information is still deciferable. Note the point of encryption is to take a randomly generated string of binary(for computers), and take an ordered set of binary, and apply some logic and make the ordered set seem random in such a way that it is still deciferable by someone who has the random sequence. To decrypt an XOR, another layer of XOR should be applied (due to XOR being an exact opposite of itself). Also note that after an OR or AND encryption, there is no way to actually unencrypt a quarter of the stored data on average, as with AND if we encrypted with a 0 we could've either started with a 0 or 1, but still get a 0, and with OR if we encrypt using a 1 and get a 1, we could've started using a 1 or 0. The method to apply for reversing an AND is to apply an AND to the two layers you have, and note that this gives a 0 at uncertain points, whereas we OR an OR encryption and note that 1 & 1 together will result in a 1, not the uncertain 1 or 0.
• I don't really understand the Bitwise problems with variables, mostly with all variables like, (X xor y) xor (y xor z).
• Keep in mind the properties of XOR, mainly commutativity and associativity in this case.
Notice how you can XOR numbers in any order to get the same result and when you XOR a number by itself, you get 0.
(1 vote)
• Is it just me, or have others skipped vlgenere cipher because you failed at first time, and doing it 5 times is way too much time spent on one exercise?
• This program does not explain the different operations used in this course. I failed each of the practice because of this factor. I did go back to the lessons, but that did not help. Is there an easier way to learn this?
• You could go to other topics inside Computer programming to know about how logic gates, numerical bases and modular arithmetic works.
(1 vote)
• Can you also discuss the PUF's? It's basically logic gates, but it is cool to show.