The other day I was talking to zone alarm licence key a friend of mine who is an art major. One way or zone alarm licence key another the topic of encryption came up. How I managed that zone alarm licence key is another story. This article, as I hope, will serve as an zone alarm licence key introduction to non-majors who has absolutely no exposure to this kind of materials.
Motivations
When datas are zone alarm licence key transmitted, most commonly over the internet or any large networks, it zone alarm licence key likely that the information will be seen by unintended parties. This is zone alarm licence key not a desirable effect but at the same time unavoidable without tremendous cost. To answer the zone alarm licence key need for confidentiality of data transmitting over networks we “encrypt” the data before transmitting.
Again..
Imagine networks as the zone alarm licence key roads. Any entity can stand on the side of public roads and zone alarm licence key observe the traffic on it, see what being transmitted, count how many cars (packets) of each type, when the road is busiest such and such.. Now our main characters here are zone alarm licence key Alice and Bob, they have the need to communicate constantly and zone alarm licence key privately. To avoid people seeing her messages when zone alarm licence key using the public road Alice can build a road from her place directly to zone alarm licence key Bob. This way any items sent from her to bob will be zone alarm licence key carried on this private road that no one else has access too. This would be zone alarm licence key much more secure and preferrable than using the public road, if not for zone alarm licence key the extra cost. Even worse when Alice now want to send messages to zone alarm licence key Cooper also. We can see building private roads for each entity you zone alarm licence key would like to communicate with is not a valid solution.
Reason Alice didn’t want to zone alarm licence key use the public roads is because people can read her message. Now if she can zone alarm licence key somehow send something totally unintelligible to Bob, then she wouldn’t mind people reading it. However at the zone alarm licence key receiving end, bob, through some procedures, must be able to zone alarm licence key turn the encrypted message back into something meaningful. If they can zone alarm licence key do this then she can use the public road as much as she wants since she is zone alarm licence key not afraid of people seeing what she is sending (because they wouldn’t understand). That is the very basic of encryption
The Shift Cipher:
I’ll introduce to zone alarm licence key you the Caesar Cipher, or Shift cipher. It works as follow. Each letter in the zone alarm licence key plain text will be replaced with another letter a few places away from zone alarm licence key it in the alphabet.
For example:
A -> C
B -> D
C -> E
D -> F
E -> G
F -> H
G -> I
H -> J
…
X -> Z
Y -> A
Z -> B
and so on.
Thus to send
HELLO THERE
you would send:
JGNNQ VJGTG
Here every letter is zone alarm licence key changed to the letter 2 places after it in the zone alarm licence key alphabet. For this cipher if you know the key k=2 you can encrypt message AND also decrypt (just move letters back 2 spaces). It is zone alarm licence key obvious that such a method is very insecure because there are zone alarm licence key only 26 possible keys. With little computational power one can easily attempt to zone alarm licence key decrypt with all 26 keys and will find one that is zone alarm licence key the correct key (this is the bruteforce attack).
But if no one know the key, then the ciphertext (the text created after the encryption process) would look totally unintelligible to zone alarm licence key a 3rd party and the communication is confidential.
And that is the very basic of data encryption.
Modulo 26
When encrypt and zone alarm licence key decrypt messages it is natural that we assign numbers to letters in the zone alarm licence key alphabet. ‘A’ would be 0 (zero), ‘B’ is 1, ‘C’ is 2, … , and ‘Z’ is 25. Now when shifting with key = 2. ‘Z’ will be shifted by 2 so it would be 25+2 = 27. But this wouldn’t make sense since we only have 26 letters (would need 28 characters to address the value 27). It is natural to apply modulo 26 to ‘Z’ =25 to give 1, or ‘B’.
we write
27 = 1 (mod 26)
26 here is called the modulo. “27 mod 26″ simply is zone alarm licence key the remainder you have after you divide the modulo into 27.
As you could imagine
27 = 2 (mod 25)
Brute-force (slowest) to find x mod n is zone alarm licence key to repeatedly subtract n from x until you get to zone alarm licence key a value that is smaller than n. Of course if x < n then x mod n is just x. Also n mod n = 0 for all valid n.
In C++ you can use the % operator to zone alarm licence key find remainder, however it does not always return a positive result. This is zone alarm licence key a simple implementation of the modulo function:
int mod(int x, int n)
{
if (0==n) return -1;
if (x<0) return (x+(-1)*(x/n)*n+n);
if (x<n) return x;
else
return x-(x/n)*n;
}