# Fundamentals of symmetric and asymmetric cryptography

Cryptography uses symmetric and asymmetric encryption for encryption and decryption of data. If the sender and the recipient of the data use the same key to encrypt and decrypt the data, it’s called symmetric encryption and if the keys are different for encryption and decryption then it's asymmetric encryption.

**What is symmetric encryption?**

Symmetric encryption is the one in which the sender and the recipient of the data use the same key to encrypt and decrypt the data. The sender and receiver must exchange the key with each other over a secure channel to maintain confidentiality and using this key the sender and receiver encrypt and decrypt the data exchanged between them.

**Symmetric encryption types**

Symmetric encryption algorithms can be categorized into two types.

They are as follows:

**Block algorithms:**As the name suggests, the data is divided into small chunks of blocks and each block is encrypted using a designated private key. Each block is of fixed size and encryption happens over each block. While each block is being encrypted, the system keeps the data in the memory until all the blocks are encrypted**Stream algorithms:**Unlike Block algorithms, in stream algorithms data is encrypted as it streams. This is considered safer compared to Stream algorithms since the system does not retain data in the memory.

**Symmetric encryption algorithms**

The following algorithms uses symmetric encryption for encrypting the data:

- AES (Advanced Encryption Standard)
- DES (Data Encryption Standard)
- IDEA (International Data Encryption Algorithm)
- Blowfish (Drop-in replacement for DES or IDEA)
- RC4 (Rivest Cipher 4)
- RC5 (Rivest Cipher 5)
- RC6 (Rivest Cipher 6)

Block ciphers: AES, DES, IDEA, Blowfish, RC5 and RC6

Stream ciphers – RC4

**Symmetric encryption applications**

- Banking sector (Payment applications like card transactions)
- Random number generation
- Validation of sender’s message
- Digital signatures

**What is asymmetric encryption?**

Asymmetric encryption is when the sender and the recipient of the data use different keys to encrypt and decrypt the data. Asymmetric encryption makes use of two keys: one for encryption and the other for decryption. The key use for encrypting the data is called a public key and the other key for decrypting the data is called a private key.

The public key is distributed publicly to the involved parties for encryption and the private key is stored on the server for decrypting the encrypted data. The private key must be stored securely on the server and should not be accessible to anyone. Anyone having access to the key can decrypt encrypted data and read the data in plain text.

Since asymmetric encryption uses two keys, it is more complex and time-consuming and requires more computational power than symmetric encryption. Asymmetric encryption ensures authentication and non-repudiation along with encryption. The usual key size involved in asymmetric encryption is 1024-4096 bits in length. Asymmetric encryption is ideal for applications where a small amount of data needs to be encrypted.

**Asymmetric encryption algorithms**

The following algorithms use asymmetric encryption for encrypting the data:

- RSA (Ron Rivest, Adi Shamir, and Leonard Adleman)
- DSA (Digital Signature Algorithm)
- ECC (Elliptic Curve Cryptography)
- Diffie-Hellman
- El Gamal

**Asymmetric encryption applications**

- Confidentiality of data
- Authenticity using digital signatures
- Integrity of information exchange
- Non-repudiation

Learn Applied Cryptography