Mohanapriya R Mohanapriya R
Updated date Jun 05, 2024
In this article, we will explore the Base64 decoding in C#. Learn how to convert encoded strings to readable text.

How to Convert Base64 Decoded Strings to Normal Strings in C#?

Base64 encoding represents binary data in ASCII format by converting it into a series of ASCII characters. To retrieve the original data, we must decode this Base64 string.

We will use the Convert.FromBase64String method, which is part of the System namespace, to do the decoding.

using System;
using System.Text;

class Program
{
    static void Main()
    {
        // Base64 encoded string
        string base64String = "V2VsY29tZSB0byBUZWNoaWVIb29rIQ==";

        // Convert Base64 string to byte array
        byte[] byteArray = Convert.FromBase64String(base64String);

        // Convert byte array to string
        string normalString = Encoding.UTF8.GetString(byteArray);

        // Display the result
        Console.WriteLine("Base64 Decoded String: " + normalString);
    }
}

Output:

Base64 Decoded String: Welcome to TechieHook!

Comments (0)

There are no comments. Be the first to comment!!!