Cryptography Cryptography is the study of different methods of encryption, decryption and cryptanalysis of data. Whenever any sensitive information is sent on internet we must think about it's safety. It should not fall in wrong hands hence it is not sent the way it is supposed to be sent. It is encrypted. I hope you know what is meant by encryption. Encryption involves changing the original data such that it looses it's original form and becomes unreadable. Only the person you wish to read the data can read it after decrypting it. That means the method of decryption is known only to you and him. You must have understood what is encryption and what is it's need. This tutorial is too big and you should understand some jargon to understand it properly. Plaintext: The original data you want to send Ciphertext: The encrypted data Cipher: The method of encryption, encryption algorithm Crypto-analysis: The method by which a crypto-analyst generates plaintext from ciphertext when nothing is known to him about plaintext or nature of cipher. Evidently it's a hackers job. The most basic cipher would be a substitution cipher. In this cipher every character in plaintext is replaced by another corresponding character. e.g. Consider a message On the full moon day. Let us replace a by b, b by c, c by d,.....,z by a. Then we get Po uif gvmm nppo ebz This the encrypted text we get. What if somebody gives you such text and tells you to decrypt? It looks difficult but not so difficult also. Any substitution cipher is the simplest to break by analysing it. Do you know that e is the most appearing character in English language? Can you use this knowledge to find out what is replaced for e? Second most appearing letter is t. Find out what is placed for t. Then with 2 observations in hand try to understand the logic of cipher. Now the job is pretty simple. This trick may not work for small sentences but works fine for long sentences. This method of breaking a cipher is called cryptoanalysis. If you can't take so much of pain to your head you can do something called bruteforcing. In this method you try all the possible substitutions. So in above case you will have to write a program that will try all the possible permutations. You can find out which one is readable and that will be the answer. You will have to try 26! permutions to get any possibility of answer and a 2 Ghz PC will hardly take 5 secs. for it. Substitution ciphers are rarely seen anywhere may be in newspaper puzzles or some detective novels. In todays world we have ciphers like md5 which are so complex that they are very difficult to understand forget about decrypting it. At the same time people have invented new methods of crypto-analysis like differential crypto-analysis. Understanding these real life algorithms is not a small boy's game. So I will tell you a few ciphers which are still rarely used. XORing is such cipher. You can xor a character in the string with it's position in the string. Understood? NO! From the darkness to a new world xor F with 0 xor r with 1 ......... You can find such cipher in the first encryption challenge at Hackthissite.org Try writing such ciphering and deciphering programs. How about bruteforcing.Can you write a program that will produce all permutations of a given set of characters? What if you want to send an email which contains very sensitive information. There is something called symmetrical ciphers. In above examples algorithm used to encrypt and decrypt is same. That is say sine is used to encrypt a number then sine inverse was used to decrypt. But that is not so safe. Hence in un symmetrical algorithms a key is used. A key is same thing like a password but very long usually 128 bit key is considered as safest. This is hardwired or kept very very secrete. This key is used to encrypt a message and also to decrypt a message. ciphertext=Cipher_function(key,plaintext) This key is shared between sender and receiver. No third person should get this key. This key is first sent to the sender through a secure medium. Then you can send the receiver the ciphertext. Plaintext is obtained using the key. plaintext=Decipher_function(key,ciphertext) This is all about symmetrical encryption.