这里调用system.web.ui.page类下的DecryptString方法,其定义如下:
internal static string DecryptString(string s) { if (s == null) { return null; } byte[] buf = HttpServerUtility.UrlTokenDecode(s); buf = MachineKeySection.EncryptOrDecryptData(false, buf, null, 0, buf.Length); return Encoding.get_UTF8().GetString(buf); }
在新建的cs页中写函数代码:
Type t = typeof(System.Web.UI.Page);
object[] args = new object[] { "t0WNtE3pVL9kAV8ZgepUcg2" };
BindingFlags bindingFlags = BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance;
string s = (string)t.InvokeMember("DecryptString", bindingFlags, null, this, args);
return s;
说明:
InvokeMember简单的讲,就是动态的调用一个Type(比如类)的特定方法.
比如上面的例子:
t.InvokeMember("DecryptString", bindingFlags, null, this, args);
就是动态的调用了类page的internal static 的方法DecryptString,参数为args.
返回string类型的s.