# Encryption and Decryption in C#

In this article, I am going to discuss various **Encryption and Decryption** technique.

There are basically two types of algorithms that are used for Encryption and Decryption.

Symmetric Encryption

In this algorithm, a single key is used for both Encryption and Decryption. It’s comparatively faster than its equivalent Asymmetric Encryption.

Symmetric Encryption is a kind of computerized algorithm that uses a specific key to secure an electronic message. Its conversion technique follows certain mathematical steps along with a private key, which makes it difficult for a hacker to decrypt. It’s a two-way algorithm where we can decrypt the cipher text using the same private key.

In this type of encryption, both sender and receiver need to know the secret key which may have some security problems.

Example of Symmetric Encryption

- Blowfish
- AES (Advanced Encryption Standard)
- RC4 (Rivest Cipher 4)
- DES (Data Encryption Standard)
- RC5 (Rivest Cipher 5)
- RC6 (Rivest Cipher 6)

Asymmetric Encryption

We have studied that Symmetric Encryption has a security concern. Here comes Asymmetric Encryption which will help to solve security concern as two different key is used for both Encryption and Decryption. One is the Public key which is used for Encryption and another is the Private key which is used for Decryption.

Asymmetric encryption is slower than symmetric encryption due to the longer key lengths and the complexity of the encryption algorithms used. In order to maintain security, asymmetric encryption must make it too difficult for a hacker to crack the public key and discover the private key.

Example of Asymmetric Encryption

- RSA (Ron
**R**ivest, Adi**S**hamir, and Leonard**A**dleman) - DSA (
**D**igital**S**ignature**A**lgorithm)

Now, Let’s dive into coding how both these Encryption techniques will work.

DES Data Encryption Standard

DES has been an old traditional way for encryption and decryption. It’s also vulnerable to hackers, therefore its demand has been in decline. Also, the key used to encrypt is very short in length.

It’s not best where data flows over the network.

AES Advanced Encryption Standard

The enhancement was a must need as **DES** has not been best due to its vulnerability and its updated version **3DES **is relatively slow.

The Advanced Encryption Standard, or AES, is also called the **Rijndael** cipher.

AES-128 uses a 128-bit key length to encrypt and decrypt a block of messages, while AES-192 uses a 192-bit key length and AES-256 a 256-bit key length to encrypt and decrypt messages. Each cipher encrypts and decrypts data in blocks of 128 bits using cryptographic keys of 128, 192, and 256 bits, respectively.

Symmetric, also known as secret keys, ciphers use the same key for encrypting and decrypting, so the sender and the receiver must both know and use the same secret key.

That’s all I have for today. I will be looking forward to putting a more detailed explanation and implementation.