# Encryption Methods

This tutorial covers some popular encryption methods. To begin you will need some things:

## 1. You need the encrypted data

You will have to find the encrypted data. Sometimes its hidden in a webpage, disguising itself as something else. Sometimes it is just written somewhere in the open, but the passkey or the referencing alphabet is hidden.

## 2. You need to know what the crypt represents

If you have a crypt, but you do not know what you are trying to find in, it you will have a much harder time. You should first try to guess what the result of the decryption is. It could be a plain text, or a picture, maybe even a binary program. And if it is text it could be special text, like mathematical expressions, coordinates or just numbers. There are many possibilities, but usually only a few make sense.

## 3. You need to know how it was encrypted, or at least have a rough guess.

To decrypt the cipher you will first have to know how it was encrypted. There are endless possibilities. First see if you can find out how it was encrypted by investigating the background of the guy that encrypted it or the circumstances of the crypt. There may be hints around. A professional cryptanalysist may need nothing but the crypt to get a good idea how it was encrypted, and even if they has no idea they may still decrypt it by using professional methods. But here for us, you should know how it was encrypted at some point during decryption.. ;)

## 4. Now what does the encrypted mean?

Lets say I have the word: "hello". Now I reverse the word, which gives me "olleh". This is a simple encryption. If someone sees this text on a piece of paper they may think it is a foreign language: "?uoy era woh yeh." But you know it's plain english, and can easily be decrypted. There are many ways to encrypt text to make it look like no text at all. If another person knows how it was encrypted, they can easily decrypt it and get the message from the crypt. First I want to point out some basic encryption methods:

## 1. Caesar cipher

Simple cipher that shifts the alphabet by a number of letters. "abcdef" shifted by 2 becomes: "cdefgh". ROT-13 for example is a rotation of the alphabet by 13 letters. ROT-13 is so popular because there are 26 letters in the alphabet so its easy to encrypt it then encrypt it a second time to get it back to normal. You can write small programs to look for this kind of easy encryption (or just use rot13.com)

## 2. Mono-alphabetic substitution

Replaces every letter with some other letter from the alphabet. No letter can be used twice of course. You will need a key that holds the mapping of the characters. The key has two parts. The first part is the original alphabet and the second part is the encryption key. Lets say "abcdef" is mapped to "fedcba". That means the word "beef" becomes "ebba". To crack those ciphers you will need to look for more frequent letters and words and guess the text... you will need a fairly large sample of ciphered text for it to work out. The word "the" for example is often used in the english language and "e" the most common letter. For other languages it will probably be different of course...

## 3. Vigenere cipher

Every letter in the word gets shifted by a certain amount that is set by the password. This means the following... lets say the password is "bcde". Now say a=1 b=2 and so on... that means the first letter of the original text is shifted 2 letters, the second one is shifted by 3 letters and so on. This works great until you run out of the password characters. (It's only 4 characters long) Then you just start from the beginning again, in this case with "b" (=2). Notice how the A is converted to a number, here one (1) in the example. This is referencing by position. We talk about that later in more detail.

## 4. One time pad (with XORing)

The safest version of encryption is a one time pad. You have a long line of random letters. Those letters are known by you and the guy that needs to decrypt the message. You now encrypt every letter of the original text with the letter at the same position in that random letter line. The result is the cipher that you send away. The guy on the other end has the one time pad and can extract the original letters by decoding with the one time pad random letters. The only bad thing is: you got to get the one time pad to the other side, hopefully without anyone else getting a copy of it they can use to decrypt your message. Additionally the receiver needs to know which pad to use for the decryption if there is more than one pad available.

Now how do you encrypt the two lines of letters with each other? You need to XOR them. First convert them to binary. A binary number consists only of 0 and 1. You can describe any letter with a binary number, either using the ASCII code of the letter as a base or using an alphabet numbering, like A=1, B=2 or similar. Now after both strings are converted to binary you have a very long line of 0 and 1s. You still know which numbers are representing which letter because you wont delete leading zeros, making it so that for example every 8 numbers represent one letter (8 bit code).

Now XOR the two strings by using an exclusive-or method. This means: if there is one 1 in between the two, the result is 1. If there are two 0 or two 1, the result is 0.

0 xor 1 = 1

1 xor 0 = 1

1 xor 1 = 0

The resulting string can be decrypted by xoring with the known passkey (the one time pad you transmitted earlier to the other side), and then finally by converting to letters again by using either ASCII codes or alphabetic numbering. (Meaning: By referencing the position in a certain known alphabet).

## Converting numbers to letters or vice versa

You already noticed how in those examples letters are becoming numbers or vice versa. Generally this is done by mapping letters to numbers in one way or another. Using computers there are generally two ways of mapping. The first one is the ASCII Table, which converts every character (letter, number, special characters) to a certain number code. You can easily find out about ASCII using a search engine. The second one is Unicode, which is a replacement for ASCII codes that became necessary cause ASCII codes are limited to representing 255 letters, leaving not enough room for all the different letters that some languages have, like chinese for example. Again, use a search engine to learn about Unicode.

Now, not using computers, you can have a reference alphabet and convert a letter to a number by its position in the alphabet, and vice versa. Lets say the alphabet is "gcqlxebm", then G = 1, C = 2, Q = 3. The most natural alphabet is of course "abcdefghijk...", so it is used quite often.

Another method to convert letters to numbers is using hex numbers. Hex numbers can have the letters A-F, representing the digits 10-15, which means if you have certain numbers they will only consist of letters... For those who dont know, HEX number are based on 16 instead of base 10 as our normal numbers are.

## Converting numbers to numbers

This may sound easy, but it is important for cryptography. Remember that you can always change the way something looks by changing it into some other number system. Our normal system is base ten, probably because we have ten fingers and toes. This means that you can easily make a number totally unusable to an attacker if you change it to another base without him knowing. A number based on 16 may look the same as a number based on 10, but its a totally different value. So make sure you know what you are looking at. If you have a very large sample of numbers and not a single digit is above 3, then it is probably the base 4 system. Generally, it can be ANY base number. You will need find out which one.

Tutorial by Raduce

## Comments

Online (last 15 mins): guapboys