Saturday, March 23, 2013

Decode and Encode a String using C#.NET

using System;
using System.Data;
using System.Text;

protected void Page_Load(object sender,eventargs e)
{
     string convertString="Hello";
     string encodeString;
     byte[] a = Encoding.Default.GetBytes(encodeString);
     encodeString=Convert.ToBase64String(a, 0, a.Length);
     Response.Write("The Encode Value is:"+ encodeString);
     string decodeString;
     byte[] decValue = Convert.FromBase64String(ValueDecode);
     decodeString=Encoding.Default.GetString(decValue);  
    Response.Write("The Decode Value is:"+ decodeString);
}