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

How to Encode and Decode Base64 Strings in C#?

Barbara Streisand
Release: 2025-01-30 12:41:08
Original
480 people have browsed it

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>
Copy after login
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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template