找回密码
 加入
搜索
查看: 5584|回复: 1

[AU3基础] 帮忙看一下,这个调用JS错在哪里?

[复制链接]
发表于 2013-8-12 11:34:26 | 显示全部楼层 |阅读模式
Local $sCode = ""
Local $sResult = ""
_JsonRead("12345aa", "","1376264789")
Func _JsonRead($pwd = "", $mailp = "",$ts = "")
     $sCode &= 'function json2str()' & @CRLF
     $sCode &= '{' & @CRLF
     $sCode &= "var pwd = '" & $pwd & "';"  & @CRLF
     $sCode &= "var p = '" & $mailp & "';"  & @CRLF
     $sCode &= "var ts = '" & $ts & "';"  & @CRLF
     $sCode &= 'var PublicKey = "CF87D7B4C864F4842F1D337491A48FFF54B73A17300E8E42FA365420393AC0346AE55D8AFAD975DFA175FAF0106CBA81AF1DDE4ACEC284DAC6ED9A0D8FEB1CC070733C58213EFFED46529C54CEA06D774E3CC7E073346AEBD6C66FC973F299EB74738E400B22B1E7CDC54E71AED059D228DFEB5B29C530FF341502AE56DDCFE9";'  & @CRLF
         $sCode &= 'var RSA = new RSAKey();' & @CRLF
         $sCode &= 'RSA.setPublic(PublicKey, "10001");' & @CRLF
     $sCode &= "var Res = RSA.encrypt(pwd+ '\n' + ts + '\n');" & @CRLF
     $sCode &= 'if (Res)' & @CRLF
     $sCode &= '{' & @CRLF
     $sCode &= 'p = hex2b64(Res);' & @CRLF
     $sCode &= 'pwd = "";' & @CRLF
     $sCode &= '}' & @CRLF
         $sCode &= 'return p' & @CRLF
     $sCode &= '}' & @CRLF
         MsgBox(0, "代码", $sCode)
     Local $oScript = ObjCreate("MSScriptControl.ScriptControl.1")
     $oScript.language = 'JavaScript'
     $oScript.AddCode($sCode)
     $sResult = $oScript.Run('json2str')
     $oScript = 0
     Return $sResult
EndFunc
MsgBox(0, "P值", $sResult)
                        
帮忙看一下,这个调用JS错在哪里?
发表于 2013-8-18 13:59:35 | 显示全部楼层
回复 1# manbutianya


JS有无错误就不知道,只是调整了一下你的差别代码而以。[/b]
   


Dim  $sResult
$sResult = _JsonRead("12345aa", "","1376264789")

 
MsgBox(0, "P值", $sResult)
                        
Exit                                                

Func _JsonRead($pwd = "", $mailp = "",$ts = "")
        Local $sCode,$sResult
     $sCode &= 'function json2str()' & @CRLF
     $sCode &= '{' & @CRLF
     $sCode &= "var pwd = '" & $pwd & "';"  & @CRLF
     $sCode &= "var p = '" & $mailp & "';"  & @CRLF
     $sCode &= "var ts = '" & $ts & "';"  & @CRLF
     $sCode &= 'var PublicKey = "CF87D7B4C864F4842F1D337491A48FFF54B73A17300E8E42FA365420393AC0346AE55D8AFAD975DFA175FAF0106CBA81AF1DDE4ACEC284DAC6ED9A0D8FEB1CC070733C58213EFFED46529C54CEA06D774E3CC7E073346AEBD6C66FC973F299EB74738E400B22B1E7CDC54E71AED059D228DFEB5B29C530FF341502AE56DDCFE9";'  & @CRLF
         $sCode &= 'var RSA = new RSAKey();' & @CRLF
         $sCode &= 'RSA.setPublic(PublicKey, "10001");' & @CRLF
     $sCode &= "var Res = RSA.encrypt(pwd+ '\n' + ts + '\n');" & @CRLF
     $sCode &= 'if (Res)' & @CRLF
     $sCode &= '{' & @CRLF
     $sCode &= 'p = hex2b64(Res);' & @CRLF
     $sCode &= 'pwd = "";' & @CRLF
     $sCode &= '}' & @CRLF
         $sCode &= 'return p' & @CRLF
     $sCode &= '}' & @CRLF
         MsgBox(0, "代码", $sCode)
     Local $oScript = ObjCreate("MSScriptControl.ScriptControl.1")
     $oScript.language = 'JavaScript'
     $oScript.AddCode($sCode)
     $sResult = $oScript.Run('json2str')
     $oScript = 0
     Return $sResult
 EndFunc
 

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-24 20:23 , Processed in 0.095639 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表