Esempio n. 1
0
        public static string GetJScript(string pMethod, string pText, string pName)
        {
            string        code    = CommFunc.ReadTextFileToStr((CommFunc.getDllPath() + @"\VerifyCode\Lib\") + pName + ".js");
            ScriptControl control = new ScriptControlClass {
                UseSafeSubset = true,
                Language      = "JScript"
            };

            control.AddCode(code);
            object[] parameters = new object[] { pText };
            return(control.Run(pMethod, ref parameters).ToString());
        }
Esempio n. 2
0
        private string RSAEncrypt(string fileName, string functionName, params object[] pams)
        {
            StreamReader reader     = new StreamReader(Environment.CurrentDirectory + @"\" + fileName);
            string       scriptCode = reader.ReadToEnd();

            ScriptControlClass sc = new ScriptControlClass();

            sc.Language = "javascript";
            sc.AddCode(scriptCode);

            object obj = sc.Run(functionName, pams);

            return(obj.ToString());
        }
Esempio n. 3
0
        public static string GetJScript(string pMethod, List <string> pTextList, string pName)
        {
            string        code    = CommFunc.ReadTextFileToStr((CommFunc.getDllPath() + @"\VerifyCode\Lib\") + pName + ".js");
            ScriptControl control = new ScriptControlClass {
                UseSafeSubset = true,
                Language      = "JScript"
            };

            control.AddCode(code);
            object[] objArray = new object[pTextList.Count];
            for (int i = 0; i < pTextList.Count; i++)
            {
                objArray[i] = pTextList[i];
            }
            object[] parameters = objArray;
            return(control.Run(pMethod, ref parameters).ToString());
        }
Esempio n. 4
0
        public static void JsRun()
        {
            ScriptControlClass sc = new ScriptControlClass();

            sc.UseSafeSubset = true;
            sc.Language      = "JavaScript";

            var jsStrText = @"function add(name){
nameList.Push(one);
    return one;
}";

            var ddd = new object[] { "张三", "李四" };

            sc.AddCode(jsStrText);
            sc.AddObject("nameList", ddd, false);

            string str = sc.Run("add", new object[] { "dsds" }).ToString();
        }
Esempio n. 5
0
        ///需要添加引用COM:Microsoft Script Control 1.0
        /// <summary>
        /// 执行JS代码并返回结果
        /// </summary>
        /// <param name="sScript">JS代码</param>
        /// <param name="sName">JS函数名</param>
        /// <returns>结果</returns>
        private static string ExecJS(string sScript, string sName)
        {
            //string sInitUrl = "http://ipangu.baidu.com/ipangu-hint/hint/hintCustAdd_init.action";
            ScriptControlClass js     = new ScriptControlClass();//使用ScriptControlClass
            object             result = null;

            try
            {
                js.Language = "javascript";
                js.Reset();
                js.Eval(sScript);                //指向js脚本
                object[] obj = new object[] { };
                result = js.Run(sName, ref obj); //传入参数执行
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result.ToString());
        }
Esempio n. 6
0
 public string Hash(string qq, string ptwebqq)
 {
     const string url = "http://0.web.qstatic.com/webqqpic/pubapps/0/50/eqq.all.js";
     //获取hash 函数代码所在JS文件
     var jsContent = HttpHelper.Get(url);
     var index = jsContent.IndexOf("P=function(", StringComparison.Ordinal);
     var end = jsContent.IndexOf(",b=function(b){c.out", StringComparison.Ordinal) - 1;
     var hashJs = jsContent.Substring(index, end - index + 1);
     var js = new ScriptControlClass { Language = "javascript" };//使用ScriptControlClass  
     js.Reset();
     js.Eval(hashJs);
     return js.Run("P", new object[] { qq, ptwebqq }).ToString();
 }