Cryptography

by | Jun 18, 2022 | Uncategorized | 0 comments

Introduction

Cryptography is the art of ensuring security by encoding messages in such a way that they become unreadable. Cryptanalysis is the process of decoding messages from an unreadable format to a readable format without understanding how they were changed from a readable form to an indistinct one. In a nutshell, it’s like breaking code.

Cryptography stands on “four” central pillars: Plain Text, Encryption Key, Cipher Text, and Decryption Key.

Plain Text: Any communication You and I have in human language takes the form of plain text or clear text. i.e., as long as the message is not formalized in any way, anyone who knows the language can understand it. We can also say that data content in a readable form can be shared over an insecure network.

Cipher Text: The output of a plain text communication codified using any acceptable scheme is known as cipher text. A cipher is an abbreviation for code or secret message.

Encryption Key: A random string of bits mixes plain-text data into unreadable text using mathematical logic. Encryption keys are classified into two types: symmetric keys and asymmetric keys. Encryption is the process of converting plain-text messages into cipher text messages.

Decryption Key: The key used to decrypt cipher-text into plain-text using a symmetric or asymmetric key to read the original message. Decryption is the reverse process of transforming cipher-text messages back to plain-text messages.

Encryption

Keeping data was not always difficult. According to history, important secrets were kept by writing them down and concealing them from educated people. In the past, blank wax writing tablets were used, and the message was simply covered in a thin layer of wax. Since then, encryption has employed increasingly complex strategies to stay one step ahead of those seeking personal data. End-to-end encryption concerns have now significantly increased cybercrime.

There are two cryptographic mechanisms depending on what keys we use. There are two kinds of keys: public and private. It is symmetric if the same key is used for encryption and decryption and asymmetric if two distinct keys are used for encryption and decryption.

Example: Person A wishes to communicate highly confidential data to Person B, but they are in two separate countries and cannot meet. One possibility is for person A to transfer the data directly to person B, but there is a considerable risk of the data being stolen by a third party.

Another alternative is that A saves the data in a file and assigns the file a secure key or lock that no one knows about. Isn’t the problem now resolved? As no one can open the file without the key, nor can they read the internal data. The next issue is determining how the receiver will know the security key. We can utilize a lock-key pair in this case. Where A buys a lock and two separate keys, the same lock may be opened with those two keys. Therefore, one key is now with A, and the second key is with B.

Types of Cryptography

Standard cryptography

  • Caesar Cipher
  • Monoalphabetic Cipher
  • Playfair Cipher
  • Substitution Cipher
  • Rotation Cipher
  • Transposition Cipher
  • Rail fence Cipher

The most used ways are the following once;

The Caesar cipher is a sort of substitution cipher in which each letter of the alphabet is replaced by a letter located a specified distance away from the original letter.

I.e., it means A=1, B=2, c=3, and so on.

ABCDEFGHIJKLMNOPQRS
12345678910111213141516171819
TUVWXYZ  
20212223242526

HOW IT WORKS: Select an integer key as there are a total of 26 alphabets in the English language. Say shift right 3 alphabets where A+3=D, B+3=E, C+3=F, and so on.

ABCDEFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMMOPQRSTUVWXYZABC

For example, what will be the encryption of VAPT. Match the letters with the table you will get the encrypted form, and it will be “YDSW. “

If the plaintext is written in English, the Caesar cipher is vulnerable to brute-force assault because it is based on a single key with 25 potential values. As a result, the key can be discovered by trying each option and seeing whether one produces a meaningful term. Once the key is located, the complete ciphertext may be precisely deciphered.

A substitution cipher encryption method in which plaintext units are substituted with ciphertext according to a predetermined system. Single letters (the most common), pairs of letters, triplets of letters, and mixes of those mentioned above, are examples of “units.”

Consider the following example: Using the previously mentioned approach, the term “cyber” yields the next alphabet.

Plain text: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Keyword: cyber
Ciphertext output: CYBERSTUVWXYZABCDE

Modern Cryptography

In today’s world, cryptography is based on encryption and decryption algorithms, which can be accomplished using symmetric, asymmetric, or hash methods.

Symmetric encryption

The goal of symmetric encryption is to take readable data, jumble it to make it unreadable, and then unscramble it when needed. The most significant aspect of symmetric encryption is that both the encryptor and the decryptor must have accessibility to the same key.

For symmetric encryption, we can simply visit the website: https://aesencryption.net/.

Let’s type our message and enter our password in the second field before clicking the “encrypt” button on the right side.

We will get the encrypted text when we click on the “encrypt” button.

Let’s see what this encrypted text is embedded with. We’ll utilize the same site for decryption and store the encrypted text with the key.

Asymmetric encryption

Asymmetric encryption scrambles legible data and then unscrambles it at the other end, but there’s a catch that each end uses a separate key. Encryptors encrypt the data with a public key, while decryptors use a private key on the other end to unscramble it again.

For asymmetric encryption, we can simply go to https://pgpkeygen.com/

Let’s click on generate PGP keys to generate the public and private keys.

We can use the public and private keys to decode the message.

Hash Method

Hashing is not a type of encryption, but it uses cryptography. Hashing transforms data into a hash, a string of data with three crucial features. The hash produced by the same data will always be the same. Given merely the hash, it is difficult to reverse it back to the original data.

It is impossible to generate another string of data that produces the same hash. The most significant function in cryptography is the hash function. A hash represents a one-to-one relationship between data; it takes an input and produces the same result. For example, we can tell someone, “Here is a file, and here is its md5 hash.”

In actuality, a hash function will always return the same sized value. For example, md5 () will always yield 128 bits regardless of the input size. Hash functions are commonly used for password storage because if an attacker obtains the hash of the password, the attacker is forced to break the hash before using it to log in.

The hash function is important in the hacking/forensic realm since it tells us whether or not a file has changed.

To determine the hash value, we may use the Hash Calculator, which we can download here.

Let’s compute some hashes for a specific file, such as md5, sha1, and so on.

Now, let’s change the content and calculate the hashes again.

Now, we have two hash values. Let us compare both of these values of the MD5 hash.

The value of the first file is 5f8cc40a558ed52da59eecde75a87bba

The value of the other file is 3c9a366ddbab9c0ebfd8e54312905f37

With the difference in terms, we may conclude there are some differences between the files. Let’s locate those using one of the main tools, “Compare it,” which you can download from here.

Let’s compare both the files chosen by hitting the “Compare files” button in the file options. With that, we get what data is changed.

There are many more hash tools available like Generate All Hashes – MD5, SHA1, SHA3, CRC32 – Online – Browserling Web Developer Tools

SHA256 Hash Generator Online (passwordsgenerator.net)

Brainfuck Language – Online Decoder, Translator, Interpreter (dcode.fr)