Basics of Cryptography
The science of safeguarding communications from outside observers is known as cryptography. Encryption techniques take the original communication (plaintext) and turn it into ciphertext, which is incomprehensible. The key enables the user to decrypt the message, ensuring that it can be read.
The methods used to safeguard information in cryptography are derived from mathematical formulas and a set of rule-based calculations known as algorithms that change information in ways that make them harder to decode. These algorithms are used to generate cryptographic keys, digitally sign documents, verify data privacy, browse the internet, and protect confidential transactions such as credit card and debit card transactions.
Before we go into detail regarding cryptography, we must first understand what keys are.
Keys:
An encryption key is a random string of bits created specifically to scramble and unscramble data. Encryption keys are generated using algorithms that ensure each one is unique and unpredictable.
Cryptography can be classified into three categories:
- Secret Key Cryptography
- Public Key Cryptography
- Hash Functions
Secret Key Cryptography
Secret key cryptography, also known as symmetric cryptography, encrypts data with a single key. Symmetric cryptography uses the same key for both encryption and decryption, making it the simplest type of cryptography. The cryptographic algorithm encrypts the data using the key in a cypher, and when the data has to be accessed again, only someone with the secret key may decrypt it.
Public Key Cryptography
Public key cryptography, commonly known as Asymmetric cryptography, encrypts data using two keys. One key is used to encrypt the message, while the other may decrypt it. In contrast to symmetric cryptography, if one key is used to encrypt, the message cannot be decrypted with the same key.
One key is kept private and is referred to as the “private key,” while the other is shared openly and can be used by anybody, thus the term “public key.”The private key cannot be obtained from the public key.The private key should not be shared and should only be kept by the user. While Public Key can be shared to any one.
Examples:
- Diffie-Hellman key exchange
- Digital Signature Standard
Usecase:
- End-to-End Encryption
- Digital Signature
Hash Functions
Hash functions are one-way, irreversible functions that protect information without allowing retrieval of the original message. Hashing is a way of converting a variable length string into a fixed length string. For each input, a good hashing algorithm will generate distinct outputs.
Well-known hashing algorithms:
- SHA-1
- md5
- SHA-256
Usecase of Hash Function
- To store password in database