Why Encryption?
The Internet is an international network consisting of individual computers and computer networks that are all interconnected by many paths. Unlike Local Area Networks where access is physically restricted to authorized users, the Internet is a public network and can be accessed by anyone.
On the Internet this can be your credit card numbers, bank account information, health/social security information, or personal correspondence with someone else.
There are generally two main types of encryption and decryption algorithms, symmetric and asymmetric. In symmetric encryption, a secret key or password is used to scramble data while decrypt the scrambled data, the same key has to be used. DES and RC2 are examples of symmetric algorithms.
While using this encryption, it is essential that the sender and receiver have a way to exchange secret keys in a secure manner. If someone knows the secret key and can figure out the algorithm, communications will be insecure. There is also the need for a strong encryption algorithm. What this means is that if someone were to have a cipher text and a corresponding plaintext message, they would be unable to determine the encryption algorithm.
How Encryption Works
The easy way of encryption is applying a mathematical function to the plain text and converting it to an encrypted cipher. The harder part is to ensure that the people who are supposed to decipher this message can do so with ease, yet only those authorized are able to decipher it. We of-course also have to establish the legitimacy of the mathematical function used to make sure that it is sufficiently complex and mathematically sound to give us a high degree of safety.
A conventional encryption scheme has five major parts:
- Plaintext - this is the text message to which an algorithm is applied.
- Encryption Algorithm - it performs mathematical operations to conduct substitutions and transformations to the plaintext.
- Secret Key - This is the input for the algorithm as the key dictates the encrypted outcome.
- Ciphertext - This is the encrypted or scrambled message produced by applying the algorithm to the plaintext message using the secret key.
- Decryption Algorithm - This is the encryption algorithm in reverse. It uses the ciphertext, and the secret key to derive the plaintext message.
Creating symmetric encryption classes
In .NET Framework is available abstract base class Symmetric Algorithm, which is able to provide general class to work with symmetric encryption classes. The code bellow shows how to use it to create each class:
Namespaces:
using System;
using System.Security.Cryptography;
Code:
static void
{



sai akkinaPosted Jul 3, 2006, 9:11 AM
This code just works fine with the same instance of the DES Class. But when i store the encrypted password in the database and retrieve and try to decrypt back, it throws an exception. Can you please tell me how can this be avoided. Thanks in advance.
iMRAN bALOUCHPosted Mar 10, 2006, 10:08 AM
Nice posting. It was very informative. I am gonna implement it and I think sooner i will be with you with few queries.