Quick helper method to encode text - CSharp System

CSharp examples for System:String Encode Decode

Description

Quick helper method to encode text

Demo Code


using System;//from  w w w  . java 2  s.c om

public class Main{
        /// <summary>
        /// Quick helper method to encode text</summary>
        /// <param name="plainText">Text that you want to be encoded</param>
        /// <returns>Encoded string that is not plain text</returns>
        public static string Encode(String plainText)
        {
            var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
            return System.Convert.ToBase64String(plainTextBytes);
        }
}

Related Tutorials