System.Web.HttpServerUtility.UrlTokenDecode C# (CSharp) Method

UrlTokenDecode() public static method

public static UrlTokenDecode ( string input ) : byte[]
input string
return byte[]
		public static byte[] UrlTokenDecode (string input)
		{
			if (input == null)
				throw new ArgumentNullException ("input");
			if (input.Length < 1)
				return new byte[0];
			byte[] bytes = Encoding.ASCII.GetBytes (input);
			int inputLength = input.Length - 1;
			int equalsCount = (int)(((char)bytes[inputLength]) - 0x30);
			char[] ret = new char[inputLength + equalsCount];
			int i = 0;
			for (; i < inputLength; i++) {
				switch ((char)bytes[i]) {
					case '-':
						ret[i] = '+';
						break;

					case '_':
						ret[i] = '/';
						break;

					default:
						ret[i] = (char)bytes[i];
						break;
				}
			}
			while (equalsCount > 0) {
				ret[i++] = '=';
				equalsCount--;
			}
			
			return Convert.FromBase64CharArray (ret, 0, ret.Length);
		}

Usage Example

Example #1
0
 /// <summary>
 /// Creates a URL value.
 /// </summary>
 public static byte[] DecodeUriTokenBytes(string input)
 {
     return(HttpServerUtility.UrlTokenDecode(input));
 }
All Usage Examples Of System.Web.HttpServerUtility::UrlTokenDecode