# Symmetric Key Cryptography

**How does symmetric encryption work?**

Data is encrypted and decrypted using the same key in symmetric encryption. It is called symmetric because the same secret key is used for both encryption and decryption. Symmetric encryption is usually much faster than asymmetric encryption, but it requires that both parties share a common key.
A shared secret between two parties is known as a session key. It is generated by one party, who then sends it to the other party in an encrypted message. Once they have received the session key, they can use it to encrypt and decrypt messages.
In order to understand how symmetric encryption works, let's look at a simple example of how Alice might send Bob a message using symmetric encryption:
Step 1: Alice generates a random session key (K) and sends it to Bob as part of an encrypted message containing all the information required for Bob to be able to decrypt this message. This includes K itself, which has been encrypted with Bob's public key (PKB).
Step 2: Bob decrypts K using his private key (PKB), which is matched up with his public key (PKB). He then uses K along with A's public key (PKA) to encrypt K so that A can decrypt it later on.
The following are some common symmetric encryption algorithms:
- AES: Advanced Encryption Standard (128-bit block size).
- Blowfish: 64-bit block size; uses 448-bit key length.
- DES: Data Encryption Standard (64-bit block size); uses 56-bit key length.
- IDEA: International Data Encryption Algorithm (128-bit block size).

**Symmetric vs. asymmetric encryption**

Data is encrypted and decrypted using a single key in symmetric encryption. The sender and receiver must agree on the key before they can communicate securely. Symmetric encryption is often called secret-key encryption because the same secret key is used by both sender and receiver.
Two keys are used in asymmetric encryption: a public key and a private key. The public key can be used to encrypt messages that can only be decrypted by the private key holder. Private keys should remain private; if someone else gets your private key, they will have access to any information encrypted with it, and they can sign messages with your public key.
Symmetric encryption is faster than asymmetric encryption but less secure because there is only one shared secret between two parties (and thus more likely to be compromised). Asymmetric encryption is slower than symmetric encryption but more secure because each party in a conversation has their own unique secret key which they never share with anyone else (and thus less likely to be compromised).
**Uses in modern computer systems**

Symmetric encryption is used in a variety of ways in modern computer systems. Here are just a few examples:
**Data at rest:**Data at rest refers to the data that is stored on devices such as hard drives and USB sticks. When this data is encrypted using symmetric key encryption, it means that only someone with access to the private key can decrypt and read the data. This is especially important for organizations where sensitive data must be protected from unauthorized parties.

**Data in transit:**Data in transit refers to data that is being transmitted over networks such as the Internet. When this data is encrypted using symmetric key encryption, it means that only someone with access to the private key can decrypt and read the data while it is in transit over public networks. This ensures that no one else can eavesdrop on your communications or intercept them for malicious purposes like identity theft or corporate espionage.