Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

how to encode data in base64 in .net

Tags: slength
 public string EncodeBase64(string data)
        {
            try
            {
                var s = data.Trim().Replace(" ", "+");
                if (s.Length % 4 > 0)
                    s = s.PadRight(s.Length + 4 - s.Length % 4, '=');
                return Encoding.UTF8.GetString(Convert.FromBase64String(s));
            }
            catch (Exception ex)
            {
                Log.FileLogger(ex.Message, LoggingType.Error); return null;
            }
        }





This post first appeared on Dot Net Tutorial For Beginners With Examples, please read the originial post: here

Share the post

how to encode data in base64 in .net

×

Subscribe to Dot Net Tutorial For Beginners With Examples

Get updates delivered right to your inbox!

Thank you for your subscription

×