Lets Have a fun with Technology.

BTemplates.com

Follow by Email

Monday, September 22, 2008

Encryption and Decryption Class In .Net.


Encryption and Decryption
There are many times Required to Descrypt Data and Stored
Data in Database Like User name and Password And 
When We Retrive That Data We Needs to Encrypt That Data.
Following Code Show How to Encrypt and Descrypt Data in Asp.Net



  public string Encry(string str)
    {
        string Tmp = "";
        int i;
        for (i = 0; i <= str.Length - 1; i++)
        {
            Char ch = Convert.ToChar((str.Substring(i, 1)));
            int asc_from_ch = ch;
            int asc2 = Convert.ToInt32(asc_from_ch) + 7;
            Char ch_from_asc = Convert.ToChar(asc2);
            Tmp = Tmp + ch_from_asc;

        }
        str = Tmp;
        return str;
    }

    public string Decry(String str)
    {
        string Tmp = "";
        int i;
        for (i = 0; i <= str.Length - 1; i++)
        {
            Char ch = Convert.ToChar((str.Substring(i, 1)));
            int asc_from_ch = ch;
            int asc2 = Convert.ToInt32(asc_from_ch) - 7;
            Char ch_from_asc = Convert.ToChar(asc2);
            Tmp = Tmp + ch_from_asc;

        }
        str = Tmp;
        return str;
    }

Call This Two Function From your Form.

ENJOY !!!!!!!!!!!!!!!!! 
 
 
Prev Post                                                      All Post                                                           Next Post

0 comments:

Post a Comment