As Cryptology has evolved over the years, there has been a constant battle with cryptographers (code-makers) and cryptanalysts (code-breakers). As codes were made, code-breakers would break the code, forcing code-makers to enhance their code.
Code-makers have an inherent problem, a problem known as the key distribution problem. How do you get someone the key to the code you made? If I used a Vigenere Sqaure Cipher, I would have to somehow inform the person I am sending the code to, the keyword that I used. Simon Singh describes this problem in The Code Book. "Imagine that a bank wants to send some confidential data to a client via a telephone line but is worried that there might be somebody tapping the wire. The bank picks a key and uses some encryption software to scramble the message. In order to decrypt the message, the client needs not only to have a copy of the encryption software on its computer, but also to know which key was used to encrypt the message. How does the bank inform the client of the key? It cannot send the key via the telephone line, because it suspects that there is an eavesdropper on the line. The only truly secure way to send the key is to hand it over in person, which is clearly a time-consuming task. A less secure but more practical solution is to send the key via a courier. In the 1970's, banks attempted to distribute keys by employing special dispatch riders who had been investigated and who were among the company's most trusted employees. These dispatch riders would race across the world with padlocked briefcases, personally distributing keys to everyone who would receive messages from the bank over the next week. As business networks grew in size, as more messages were sent, and as more keys had to be delivered, the banks found that this distribution process became a horrendous logistical nightmare, and the overhead costs became too high" (Singh 1999, p. 251).
In 1974, two men, Martin Hellman and Whitfield Diffie met together to discuss the key distribution problem. Over the course of a couple years, Diffie and Hellman discussed various mathematical functions that could solve the problem. They focused their attention on one-way functions (functions that are easy to do, but very hard to undo). They researched the field of modular arithmetic because modular arithmetic seems to be filled with one-way functions. In 1976, Hellman and Diffie finally discovered a solution to the key distribution problem. The solution has come to be known as "public key distribution." To quickly illustrate how this works, consider a padlock. If you wanted to write a message to me, but wanted to keep it a secret, you could lock it in a box using a padlock that I provided you. This padlock is a public key. A public key is a key that everyone in the world has access to. Once you have put your message in the box and closed the padlock, it is secure. You cannot open the padlock because you do not have the key to the padlock. You only possess the power to push the padlock shut. You then send the box with message in it to me, and I then unlock the padlock with my own personal private key, a key that no one else has access to.
Whether you realize it or not, you have used public key cryptography. Have you ever done online banking? Purchased anything on Amazon or eBay? Sent an email? All of these things require what is known as RSA encryption, the most popular form of public key cryptography. The following videos are very helpful in understanding how public key cryptography works.