Example #1
0
 public static string Base64UrlEncode(this byte[] input)
 {
     if (input == null)
     {
         throw new ArgumentNullException(nameof(input));
     }
     return(input.Base64UrlEncode(0, input.Length));
 }
Example #2
0
        public static string Base64UrlEncode(this byte[] input, int offset, int count)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }
            ValidateParameters(input.Length, nameof(input), offset, count);
            // Special-case empty input
            if (count == 0)
            {
                return(string.Empty);
            }
            var buffer         = new char[count.GetArraySizeRequiredToEncode()];
            var numBase64Chars = input.Base64UrlEncode(offset, buffer, 0, count);

            return(new string(buffer, 0, numBase64Chars));
        }