Home >Backend Development >C++ >How to Encode and Decode Base64 Strings in C#?

How to Encode and Decode Base64 Strings in C#?

Barbara Streisand
Barbara StreisandOriginal
2025-01-30 12:41:08482browse

How to Encode and Decode Base64 Strings in C#?

Code and decoding of Base64 string in C#

String coding

To encodes the string to Base64, please use the

method as shown below: Base64Encode

<code class="language-csharp">public static string Base64Encode(string plainText) 
{
    byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
    return System.Convert.ToBase64String(plainTextBytes);
}</code>
Strough decoding

To decode the base64 coding string, please use

Method: Base64Decode

The above is the detailed content of How to Encode and Decode Base64 Strings in C#?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn