Encode a string in Base64 (UTF8) - CSharp System

CSharp examples for System:String Base64

Description

Encode a string in Base64 (UTF8)

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Globalization;
using System;//from w  ww . j  a  v  a  2s .  c o m

public class Main{
        /// <summary>
        /// Encode a string in Base64 (UTF8)
        /// </summary>
        /// <param name="decodedValue"></param>
        /// <returns></returns>
        public static string Base64Utf8Encode(string decodedValue)
        {
            byte[] encData_byte = new byte[decodedValue.Length];
            encData_byte = System.Text.Encoding.UTF8.GetBytes(decodedValue);
            return Convert.ToBase64String(encData_byte);
        }
}

Related Tutorials