Skip to main content

Cryptography - Science of secret messages

source: IEEE

Do you love sending secret messages? Do you love how Harvard professor Robert Langdon solves the puzzles and reveals the truth? or, do you love how Nazis created the Enigma Machine and caused problems to the Allied powers during the WW2? If answers to the above questions are yes, then I am sure you'd love cryptography.

In this introductory post, we will discuss the basics of Cryptography (mostly in the context of computer science) and in the later posts in this series, we will look into various algorithms in cryptography.

So, without any much delay, let's jump into the fascinating world of secret/secured communications, ciphers, codes and many more.


Let's say Alice wants to send some message to Bob but she fears that someone might intercept it. She doesn't want that. NO ONE wants that! (remember the Cambridge Analytica fiasco by Facebook?). To achieve the secrecy, Alice encrypts the message and replaces alphabets with numbers and numbers with alphabets in the message.

For e.g., if the message is - "I want 2 sugar cubes in my tea", then it will be encrypted as - "9 23 1 14 20 B 19 21 7 1 18 3 19 2 5 19 9 14 13 25 20 5 1". 

Now, if in between Charlie wants to read this message he will not be able to do so as the numbers and a single alphabet won't make sense to him.
Hence, Alice has encrypted the message. She will now explain Bob to replace numbers with alphabets and vice-versa. Bob, then will apply the reverse procedure and will be able to read the message. Thus, Bob has decrypted the message. 

The mechanism of converting numbers to alphabets and vice-versa is called the key of the process. Thus, to encrypt a message we need a key and to decrypt it also, we need a key. 
If I put in simple words, Cryptography is the science of keeping a message secret.


Some commonly used terms in cryptography are described below -

  • Plaintext - message which is in the human readable form and needs to be encrypted. The process of disguising a message is encryption. An encrypted message is a ciphertext. The process of turning ciphertext back into plaintext is decryption.
  • Cipher (or Cypher) - an algorithm for performing encryption or decryption
  • Cryptosystem - an implementation of cryptographic techniques and their accompanying infrastructure to provide information security services. A cryptosystem is also referred to as a cipher system.
  • Symmetric Algorithm - This is the simplest kind of encryption that involves only one secret key to cipher and decipher information. t uses a secret key that can either be a number, a word or a string of random letters. It is blended with the plain text of a message to change the content in a particular way. The sender and the recipient should know the secret key that is used to encrypt and decrypt all the messages.
source: ssl2buy
  • Asymmetric Algorithm - It uses two keys to encrypt a plain text. Secret keys are exchanged over the Internet or a large network. It ensures that malicious persons do not misuse the keys.
source: ssl2buy

The concept of Public and Private Keys

Public and Private key pair helps to encrypt information that ensures data is protected during transmission. 

Public key uses asymmetric algorithms that convert messages into an unreadable format. A person who has a public key can encrypt the message intended for a specific receiver. The receiver with the private key can only decode the message, which is encrypted by the public key. The key is available via the publicly accessible directory.

The private key is a secret key that is used to decrypt the message and the party knows it that exchange message. In the traditional method, a secret key is shared within communicators to enable encryption and decryption of the message, but if the key is lost, the system becomes void. To avoid this weakness, PKI (public key infrastructure) came into force where a public key is used along with the private key. PKI enables internet users to exchange information in a secure way through the use of a public and private key.

Digital Signatures

As per Wikipedia, "A digital signature is a mathematical scheme for presenting the authenticity of digital messages or documents. A valid digital signature gives a recipient reason to believe that the message was created by a known sender (authentication), that the sender cannot deny having sent the message (non-repudiation), and that the message was not altered in transit (integrity)".

Applying the signature

  • Using a mathematical algorithm, a hash of the document is created. This hash is specific to this particular document; even the slightest change would result in a different hash. 
source: globalsign
  • Now, this hash is encrypted using the private key and combined with the public key to form a digital signature and appended to the document. Now, this digital signature is distributed.

Verifying the signature

  • If the document is opened by any digital signature-capable program, it automatically uses the signer's public key to decrypt the document hash.
  • The program calculates a new hash for the document. If this new hash matches the decrypted hash from Step 1, the program knows the document has not been altered.
source: globalsign
The program also validates that the public key used in the signature belongs to the signer and displays the signer's name.


In this post, we discussed the basics of cryptography, common terminologies, and concepts of digital signature and keys. I hope you enjoyed this post. In the upcoming posts, we will look into various algorithms that are used in cryptography and their implementation using code. You can also follow me on Twitter. Happy learning!! 😊


  1. Really helpful down to the ground, happy to read such a useful post. I got a lot of information through it and I will surely keep it in my mind. Keep sharing. What does a information security auditor do


Post a Comment

Popular posts from this blog

Parsing XML using Retrofit

Developing our own type-safe HTTP library to interface with a REST API can be a real pain as we have to handle many aspects - making connections caching retrying failed requests threading response parsing error handling, and more.  Retrofit, on the other hand, is a well-planned, documented and tested library that will save you a lot of precious time and headaches. In this tutorial, we are going to discuss how we can parse the XML response returned from  using the Retrofit library. To work with Retrofit, we need three classes -  Model class to map the JSON data Interfaces which defines the possible HTTP operations Retrofit.Builder class - Instance which uses the interface and the Builder API which allows defining the URL endpoint for the HTTP operation. Every method of the above interface represents on possible API call. The request type is specified by using appropriate annotations (GET, POST). The respon

Threads in Java - Masterclass (Part 0)

Threads in Java Multithreading is a way to introduce concurrency in a program. In any case, if there are parallel paths in our program (parts which do not depend on the result from another part), we can make use of multithreading. One should exploit this feature, especially with all these multiple core machines nowadays. Below are a few reasons why we should use multithreading - 1. Keep a process responsive There was once a time when you would print a document in MS Word and the application would freeze for an annoyingly long amount of time until the job finished. Eventually, Microsoft solved this problem by running a printing job parallel to the main thread/ GUI thread.  To be clear though, not only GUI apps but Network services have to keep an ear to the ground for new clients, dropped connections and cancellation requests. In either case, it is critical to do the heavy lifting on a secondary thread to keep the user satisfied. 2. Keep a processor busy Keeping a proc

Material design profile page in Android

Hey everyone, some days back I was working on one my personal Android project. In that project, I was supposed to create a simple profile page for a user. This profile page was supposed to show some basic details of a user. The output of this UI will be like this - Profile page screen I created the profile page using material design and in this post, I am going to discuss a step by step tutorial to create a simple yet elegant profile page. Without further ado, let's get started. Creating a new project Click on File ➤ New Project ➤ Empty Activity and fill the necessary details. Change styles.xml file Navigate to app\src\main\res\values\styles.xml Change the style value from DarkActionBar to NoActionBar as below <resources> <!-- Base application theme. --> <style name= "AppTheme" parent= "Theme.AppCompat.Light.NoActionBar" > <!-- Customize your theme here. --> <item name= "colorPr