UrlBase64Encoder.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.IO;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Encoders
  6. {
  7. /**
  8. * Convert binary data to and from UrlBase64 encoding. This is identical to
  9. * Base64 encoding, except that the padding character is "." and the other
  10. * non-alphanumeric characters are "-" and "_" instead of "+" and "/".
  11. * <p>
  12. * The purpose of UrlBase64 encoding is to provide a compact encoding of binary
  13. * data that is safe for use as an URL parameter. Base64 encoding does not
  14. * produce encoded values that are safe for use in URLs, since "/" can be
  15. * interpreted as a path delimiter; "+" is the encoded form of a space; and
  16. * "=" is used to separate a name from the corresponding value in an URL
  17. * parameter.
  18. * </p>
  19. */
  20. public class UrlBase64Encoder
  21. : Base64Encoder
  22. {
  23. public UrlBase64Encoder()
  24. {
  25. encodingTable[encodingTable.Length - 2] = (byte) '-';
  26. encodingTable[encodingTable.Length - 1] = (byte) '_';
  27. padding = (byte) '.';
  28. // we must re-create the decoding table with the new encoded values.
  29. InitialiseDecodingTable();
  30. }
  31. }
  32. }
  33. #pragma warning restore
  34. #endif