Click here to Skip to main content
16,015,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a text box, a label and a button.I need to encrypt and display the values entered in the textbox in my label.I referred this link.But am not able to implement it as i am a newbie to c# programming.Kindly help me for this with the correct code using the encrypt function in this link.
Encryption/Decryption Function in .NET using the TripleDESCryptoServiceProvider Class[^]
help me friends with correct code for button click...
Posted
Updated 7-Aug-12 0:47am
v3

Check this LINK it might be useful and easy for you.
 
Share this answer
 
 
Share this answer
 
C#
public string base64Encode(string data)
    {
        try
        {
            byte[] encData_byte = new byte[data.Length];
            encData_byte = System.Text.Encoding.UTF8.GetBytes(data);
            string encodedData = Convert.ToBase64String(encData_byte);
            return encodedData;
        }
        catch (Exception e)
        {
            throw new Exception("Error in base64Encode" + e.Message);
        }
    }

    public string base64Decode2(string sData)
    {
        System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
        System.Text.Decoder utf8Decode = encoder.GetDecoder();
        byte[] todecode_byte = Convert.FromBase64String(sData);
        int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
        char[] decoded_char = new char[charCount];
        utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
        string result = new String(decoded_char);
        return result;
    }

Use this Two method to Encrypt and decrypt your string.
 
Share this answer
 
v2
Comments
ajithk444 7-Aug-12 7:19am    
hi, i want to use md5 encryption. can u post me code using md5 for getting value from a textbox and displaying encrypted value in a label when i click submit button.refer this link (http://www.codeproject.com/Tips/306620/Encryption-Decryption-Function-in-Net-using-MD5Cry)for the code and give me the exact code . i dono implement from this. that s wy asking here ..help me friend

protected void btnHashing_Click(object sender, EventArgs e)
{


}
thanks fr ur feedback friends. i got it...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900