DCSIMG

 Subscribe in a reader

Screen cast: Using Cryptography Application Block to Encrypt & Decrypt QueryStrings - Guy kolbis
Sunday, August 05, 2007 4:50 PM kolbis

Screen cast: Using Cryptography Application Block to Encrypt & Decrypt QueryStrings

In this screen cast, I will be show how to use the cryptography application block in order to encrypt and decrypt query string parameters. In addition I am attaching the source code for the screen cast here.

 

You can download the screen cast from here.

Screen cast walk-through

In this screen cast I will create a web site application that will contain two pages: Default.aspx and Default2.aspx. The first page will ask the user for a product id input, then it will encrypt it and perform a redirection to the second page while passing the encrypted product id. The second page will decrypt the product id and will display it on screen.

Security Helper 

The encryption and decryption will be done through a security helper that in turns will invoke methods exposed by the Cryptography application block. Here is the piece of code that invokes those operations:

public static class SecurityHelper
{
    public static string Encrypt(string string2Encrypt)
    {
        byte[] arr =
            CryptographyUtility.GetBytesFromHexString(string2Encrypt);

        byte[] arr2 =
            Cryptographer.EncryptSymmetric("RijndaelManaged", arr);

        return CryptographyUtility.GetHexStringFromBytes(arr2);
    }

    public static string Decrypt(string string2Decrypt)
    {
        byte[] arr =
            CryptographyUtility.GetBytesFromHexString(string2Decrypt);

        byte[] arr2 =
            Cryptographer.DecryptSymmetric("RijndaelManaged", arr);

        return CryptographyUtility.GetHexStringFromBytes(arr2);
    }
}

Cryptography Utility

The Cryptography Application Block includes a CryptographyUtility Class that it uses internally. I will use it to get the bytes from HexString and get the HexString back from the bytes.

Cryptographer

The Cryptographer is a Facade for using the Cryptographer application block. By using the Cryptographer Class encrypting and decrypting is very simple.

תגים:, , ,

תוכן התגובה

# re: Screen cast: Using Cryptography Application Block to Encrypt & Decrypt QueryStrings

Joeliste כתב/ה

excellent !

Thanks a lot

Monday, August 24, 2009 12:00 PM

שלח תגובה

(שדה חובה) 
(שדה חובה) 
(אופציונלי)
(שדה חובה) 

Enter the numbers above: