Sponsored Ad

Wednesday, April 6, 2011

Decode Base64 String in Normal String in C#

You have an encoded base 64 string and want to convert into a normal string string. The below C# code will help you to convert into a normal string.

Use FromBase64String method of Convert class to convert into a normal string.

Decode Base64 String in Normal String in C#

using System;

namespace MyApp
{
    public class Decode_Base64_Class
    {
        public static void Main(string[] args)
        {
            string myStr = "SharePoint Tutorials: SharePointBank.com";

            string strBase64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(myStr));
            Console.WriteLine("Base 64 String:\n " + strBase64);

            //Decoding process from Base64 String
            string strNormal = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(strBase64));
            Console.WriteLine("Normal String :\n " + strNormal);          
            Console.ReadLine();
        }
    } 
}

No comments:

Post a Comment

Development Updates