Base64-encodes a string - CSharp System

CSharp examples for System:String Base64

Description

Base64-encodes a string

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using System.Globalization;
using System;/*ww  w  .  j  a v  a2  s.c  o  m*/

public class Main{
        #endregion

		#region Methods: Encoding

		/// <summary>
		/// Base64-encodes a string
		/// </summary>
		public static string EncodeBase64(this string value)
		{
			var bytes = Encoding.ASCII.GetBytes(value);

			return Convert.ToBase64String(bytes);
		}
}

Related Tutorials