by ghost107 on Tue May 19, 2015 2:26 pm
([msg=88118]see Re: Different types of ciphers besides Caesar Cipher?[/msg])
- The substitution method:
Similar to caesar cypher the substitution method is replacing every character in the alphabet with another character from the alphabet.
- Code: Select all
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Z I R A J S B K T C L U D M V E N W F O X G P Y H Q
- The mathematical Method of the caesar cypher:
Same as the caesar cypher, every character is assigned a number and the encryption is C= (P+3) mod 26, this is a simple example, here you can apply many mathematical algorithms to shift the character.
- Code: Select all
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
- Hill cypher
Which also is a polygraph or block cypher. To avoid the vulnerability of the caesar and substitution, the Hill method divides the text into multiple blocks of the same length.
- Code: Select all
THIS IS A MESSAGE
Dividing the text message into small blocks of equal size(if the size of the last block is not even, fill the rest of the block with X):
- Code: Select all
TH IS IS AM ES SA GE
Replacing it with a number (the mathematical approach of the caesar cypher)
- Code: Select all
{19, 7} {8, 18} {8, 18} {0, 12} {4, 18} {18, 0} {6, 4}
For each element in the block we have a matrix A with same rows and columns as the block length.
- Code: Select all
|x1 y1|
A = | |
|x2 y2|
The matrix A is applied to each block in the text, the bigger the block the complexer the encryption is.
- Code: Select all
|C1| |P1|
| | = A*| |
|C2| |P2|
To decrypt it you would need the inverse of A, instead of A:
- Transposition method:
The transposition cypher is a much efficient method then the substitution, but it has a lot of disadvantages. The encrypted text has all the character from the initial text, but in a different order, uses a matrix of the order MxN where it interchanges the rows and columns to form a different matrix.
Lets take the text the "This message uses the transposition method"(The example below only switched the rows)
- Code: Select all
1 2 3 4 5 6 7 1 2 3 4 5 6 7
1 T h i s m e s 3 s t h e t r a
2 s a g e u s e 4 n s p o s i t
3 s t h e t r a 1 T h i s m e s
4 n s p o s i t => 2 s a g e u s e
5 i o n m e t h 6 o d x x x x x
6 o d x x x x x 5 i o n m e t h
7 x x x x x x x 7 x x x x x x x
- DES (Data Encryption Standard)
Its kinda hard to explain but DES is a Feistel Cypher which processes blocks of 64 bits, creating encrypted blocks of 64 bits. The size of the secret key k is 56 bits, the input key is 64 bits, where 8 bits are used as parity bits(8, 16, 24, 32, 40, 48, 56, 64).
- The encryption happens in 16 rounds, from the input Key K are generated 16 subkeys of 48 bits size(one key for each round)
- Each round has 8 fixed substitutions
- The text block of 64 bits is divided into two 32 bit sub-blocks
- Code: Select all
IP - Initial permutation (google it)
E - Expand, used to expand the block from 32 to 48 bits to apply the key
S - Fixed substitutions, the function that applies the 8 fixed substitutions
PC1, PC2 - Permuted Choice, a 56 bit permutation table
Vi - circular left shifting on the i round(16 rounds vi = 1 when i = {1,2, 9,16}, vi = 2 in the rest)
Key Generation Algorithm:
- Apply PC1 to the Input key
- Divide the result of the PC1 into two 28 bit (C0, D0)
- For each subkey(ki) to generate (16 keys)
Ci = Ci-1 <- vi
Di = Di-1<-vi
- The subkey is the result of the PC2, ki = PC2(Ci, Di)
Algorithm:
- Compute 16 subkeys from the input key
- Use IP(text_block), and divide the result into two 32 bit blocks (L0, R0)
- Run 16 rounds for (Li, Ri), where i is a value from 1 to 16
Li = Ri-1;
Ri = Li-1 (+) f(Ri-1, Ki), where f(Ri-1, Ki) = P(S(E(Ri-1) (+) Ki))
- Switching the final block( L16, R16) =>(R16, L16)
- Applying the inverse of the IP to the final switched rounds(R16, L16), the result is the encrypted block
Triple DES is a DES encryption with 3 keys- Code: Select all
Encrypt(Decrypt(Encrypt(text, k1), k2),k3)
AES the functionality is similar to DES, to understand AES you must first understand how DES works.
You could also look into RC4, RC5, RC6.