Encryption and decryption using C#.net

      Encryption is the process of translating plain text data into something that appears to be random and meaningless.

Decryption is the process of translating random and meaningless data to plain text.


    Use the using statement on the following namespaces: 
·         System
·         System.Security
·         System.Security.Cryptography
·         System.Text
·         System.IO

      There are many modern cryptographic methods used for encryption and decryption and it is classified in to two classes of key based algorithms.

1.  Symmetric Algorithm
a.       Same key is used for both Encryption and Decryption. The key will be kept as secret.
b.       Symmetric Ciphers is divided into Stream and Block Ciphers.
                  i.      Stream Ciphers – It encrypts a single bit of plain text at a time.
                 ii.      Block Ciphers –   It takes number of bits and encrypts them as a single unit.
2.  Asymmetric Algorithm
a.       Different key is used for Encryption and Decryption. It is also called as public Key algorithm.
b.       Encryption key is public and the Decryption key will be kept as secret.
c.       By using this asymmetric algorithm, anyone can encrypt the message by using encryption key but
          the message can be decrypted only by using decryption key.



1. Triple DES
      Triple DES was designed to replace the original Data Encryption Standard (DES) algorithm, which hackers eventually learned to defeat with relative ease. At one time, Triple DES was the recommended standard and the most widely used symmetric algorithm in the industry.
      Triple DES uses three individual keys with 56 bits each. The total key length adds up to 168 bits, but experts would argue that 112-bits in key strength is more like it.
      Despite slowly being phased out, Triple DES still manages to make a dependable hardware encryption solution for financial services and other industries.
2. RSA
      RSA is a public-key encryption algorithm and the standard for encrypting data sent over the internet. It also happens to be one of the methods used in our PGP and GPG programs.
      Unlike Triple DES, RSA is considered an asymmetric algorithm due to its use of a pair of keys. You’ve got your public key, which is what we use to encrypt our message, and a private key to decrypt it. The result of RSA encryption is a huge batch of mumbo jumbo that takes attackers quite a bit of time and processing power to break.
3. Blowfish
      Blowfish is yet another algorithm designed to replace DES. This symmetric cipher splits messages into blocks of 64 bits and encrypts them individually.
      Blowfish is known for both its tremendous speed and overall effectiveness as many claim that it has never been defeated. Meanwhile, vendors have taken full advantage of its free availability in the public domain.
      Blowfish can be found in software categories ranging from e-commerce platforms for securing payments to password management tools, where it used to protect passwords. It’s definitely one of the more flexible encryption methods available.
4. Twofish
      Computer security expert Bruce Schneier is the mastermind behind Blowfish and its successor Twofish. Keys used in this algorithm may be up to 256 bits in length and as a symmetric technique, only one key is needed.
      Twofish is regarded as one of the fastest of its kind, and ideal for use in both hardware and software environments. Like Blowfish, Twofish is freely available to anyone who wants to use it. As a result, you’ll find it bundled in encryption programs such as PhotoEncrypt, GPG, and the popular open source software TrueCrypt.
5. AES
      The Advanced Encryption Standard (AES) is the algorithm trusted as the standard by the U.S. Government and numerous organizations.
       Although it is extremely efficient in 128-bit form, AES also uses keys of 192 and 256 bits for heavy duty encryption purposes.
      AES is largely considered impervious to all attacks, with the exception of brute force, which attempts to decipher messages using all possible combinations in the 128, 192, or 256-bit cipher. Still, security experts believe that AES will eventually be hailed the de facto standard for encrypting data in the private sector.