Difference between revisions of "Cryptography"

From Game Detectives Wiki
Jump to: navigation, search
[unchecked revision][checked revision]
m (Binary cipher)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Cryptography is the process of hiding messages; either by concealing them (eg. hiding them in an image), or by obfuscating them outright (eg. substitution cipher).
+
To learn about cryptography, check out the [http://gamedetectives.net/academy Game Detectives Academy] - a free, interactive series of tutorials!
 
 
== Basic Terminology ==
 
 
 
* '''Cipher''': a method of encryption
 
* '''Plaintext''': the legible text of a hidden message
 
* '''Ciphertext''': the text after a message is concealed in it
 
* '''Encryption''': The process of turning plaintext into ciphertext
 
* '''Decryption''': The process of converting ciphertext back into plaintext
 
* '''Key''': a string used in the encryption and decryption processes of some ciphers, akin to a password
 
 
 
== Basic Ciphers ==
 
 
 
=== Caesar cipher ===
 
 
 
''Click [http://www.xarg.org/tools/caesar-cipher/ here] to experiment with the Caesar cipher.''
 
 
 
The simplest example of a cipher is the Caesar cipher.  The rules of the cipher are as follows:
 
 
 
Let '''n''' equal a value from 1 to 25
 
Shift each letter in the plaintext forward by '''n''' positions in the alphabet
 
The resultant string is the ciphertext
 
 
 
For example, to encrypt the string <code>Game Detectives</code> using the Caesar cipher, using an arbitrary '''n''' value of 2, then:
 
 
 
G -> H -> I
 
a -> b -> c
 
m -> n -> o
 
e -> f -> g
 
...
 
 
 
and the resultant ciphertext would be <code>Icog Fgvgevkxgu</code>.  To decrypt this string back into <code>Game Detectives</code>, the process can simply be reversed by shifting each letter of the ciphertext 2 places backwards.  (''Note: another common name for the Caesar cipher is ROT<n> - ROT13 indicates that each letter is shifted halfway through the alphabet)''
 
 
 
=== Binary cipher ===
 
 
 
''Click [http://www.binaryhexconverter.com/binary-to-ascii-text-converter here] to experiment with the binary cipher.''
 
 
 
'''What is binary?'''
 
 
 
Binary is a system of counting, used by computers, that is different than the typical system of counting.  You're used to counting by using 10 different digits: 0 to 9.  This is known as '''base 10''', or decimal.  Binary only uses 2 digits: 0 and 1, so it is known as '''base 2'''.  Let me give you an example.
 
 
 
This is how you write the number ''one hundred and nine'' normally, in base-10.  The top row represents the values of each digit place; you can see that, starting from the right-hand side and moving left, each consecutive decimal place is worth '''10 times more''' than the previous one in '''base 10'''.  The bottom row can use digits from 0 to 9.
 
+-----+-----+-----+
 
| 100 | 10  |  1  |
 
+-----+-----+-----+
 
|  1  |  0  |  9  |
 
+-----+-----+-----+
 
1*100 + 0*10 + 9*1
 
= 100 + 0 + 9
 
= 109
 
 
 
Okay, now, here's how you write the same number, ''one hundred and nine,'' in base-2.  Again, the top row represents the values of each digit place; but this time, each decimal place is only worth '''2 times more''' than the previous one in '''base 2'''.  Now, the bottom row can only use the digits 0 and 1.
 
 
 
+-----+-----+-----+-----+-----+-----+-----+-----+
 
| 128 | 64  | 32  | 16  |  8  |  4  |  2  |  1  |
 
+-----+-----+-----+-----+-----+-----+-----+-----+
 
|  0  |  1  |  1  |  0  |  1  |  1  |  0  |  1  |
 
+-----+-----+-----+-----+-----+-----+-----+-----+
 
0*128 + 1*64 + 1*32 + 0*16 + 1*8 + 1*4 + 0*2 + 1*1
 
= 0 + 64 + 32 + 0 + 8 + 4 + 0 + 1
 
= 109
 
 
 
So, the base-10 (decimal) number of 109 is equal to the base-2 (binary) number of 01101101.
 
 
 
'''How is binary used in a cipher?'''
 
 
 
The binary cipher relies on the fact that each ASCII character that you can type on your keyboard has a unique identifying code, in binary.  For example,
 
 
 
* Uppercase <code>A</code> has a ASCII code, in binary, of <code>01000001</code> (converting to <code>65</code> in decimal)
 
* Lowercase <code>a</code> has a ASCII code, in binary, of <code>01100001</code> (converting to <code>97</code> in decimal)
 
* Ampersand <code>&</code> has a ASCII code, in binary, of <code>00100110</code> (converting to <code>38</code> in decimal)
 
* Plus sign <code>+</code> has a ASCII code, in binary, of <code>00101011</code> (converting to <code>43</code> in decimal)
 
 
 
So, all that is required to encrypt a binary cipher is to convert the ASCII characters into their codes - and to decrypt the cipher, the codes are changed into the characters.  For instance, encoding the string <code>Game Detectives</code> would give you:
 
 
 
+-------+--------+
 
| ASCII | Binary |
 
+-------+--------+
 
|  G  |01000111|
 
|  a  |01100001|
 
|  m  |01101101|
 
|  e  |01100101|
 
|  and so on...  |
 
+-------+--------+
 
01000111 01100001 01101101 01100101 00100000 01000100 01100101 01110100 01100101 01100011 01110100 01101001 01110110 01100101 01110011
 

Latest revision as of 14:37, 24 May 2018

To learn about cryptography, check out the Game Detectives Academy - a free, interactive series of tutorials!