base 64 url encode - CSharp System

CSharp examples for System:String Base64

Description

base 64 url encode

Demo Code


using System;//  www .  ja v a2  s  .c  om

public class Main{
        public static string base64urlencode(byte[] arg)
        {
            string s = Convert.ToBase64String(arg); // Regular base64 encoder
            s = s.Split('=')[0]; // Remove any trailing '='s
            s = s.Replace('+', '-'); // 62nd char of encoding
            s = s.Replace('/', '_'); // 63rd char of encoding
            return s;
        }
}

Related Tutorials