public ToPercentEncodedTransform(ToPercentEncodedTransformMode mode)
        {
            switch (mode & ToPercentEncodedTransformMode.ModeMask) {
            case ToPercentEncodedTransformMode.Rfc2396Uri:
              escapeOctets = GetEscapeOctets(rfc2396UriEscapeChars);
              break;
            case ToPercentEncodedTransformMode.Rfc2396Data:
              escapeOctets = GetEscapeOctets(rfc2396DataEscapeChars);
              break;
            case ToPercentEncodedTransformMode.Rfc3986Uri:
              escapeOctets = GetEscapeOctets(rfc3986UriEscapeChars);
              break;
            case ToPercentEncodedTransformMode.Rfc3986Data:
              escapeOctets = GetEscapeOctets(rfc3986DataEscapeChars);
              break;
            case ToPercentEncodedTransformMode.Rfc5092Uri:
              escapeOctets = GetEscapeOctets(rfc5092AChars);
              break;
            case ToPercentEncodedTransformMode.Rfc5092Path:
              escapeOctets = GetEscapeOctets(rfc5092BChars);
              break;
            default:
              throw new NotSupportedException(string.Format("unsupported transform mode: {0}", mode));
              }

              escapeSpaceToPlus = (int)(mode & ToPercentEncodedTransformMode.EscapeSpaceToPlus) != 0;
        }
Beispiel #2
0
        public static byte[] Encode(string str, ToPercentEncodedTransformMode mode, Encoding encoding)
        {
            if (encoding == null)
            throw new ArgumentNullException("encoding");

              return ICryptoTransformExtensions.TransformBytes(new ToPercentEncodedTransform(mode),
                                                       encoding.GetBytes(str));
        }
Beispiel #3
0
 public static string GetEncodedString(byte[] bytes, ToPercentEncodedTransformMode mode)
 {
     return Encoding.ASCII.GetString(ICryptoTransformExtensions.TransformBytes(new ToPercentEncodedTransform(mode),
                                                                         bytes));
 }
Beispiel #4
0
 public static string GetEncodedString(string str, ToPercentEncodedTransformMode mode, Encoding encoding)
 {
     return ICryptoTransformExtensions.TransformStringTo(new ToPercentEncodedTransform(mode),
                                                   str,
                                                   encoding);
 }
Beispiel #5
0
 public static string GetEncodedString(string str, ToPercentEncodedTransformMode mode)
 {
     return GetEncodedString(str, mode, Encoding.ASCII);
 }
Beispiel #6
0
 public static byte[] Encode(string str, ToPercentEncodedTransformMode mode)
 {
     return Encode(str, mode, Encoding.ASCII);
 }