找回密码
 加入
搜索
查看: 2900|回复: 2

字符串加密无效,怎么回事?

[复制链接]
发表于 2008-5-20 08:24:19 | 显示全部楼层 |阅读模式
这个帮助中的例子,_StringEncrypt返回的结果是空串而@error <> 1。
为什么
#include <GuiConstantsEx.au3>
#include <String.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
    Local $WinMain, $EditText, $InputPass, $InputLevel, $UpDownLevel, $EncryptButton, $DecryptButton, $string
    ; GUI and String stuff
    $WinMain = GUICreate('Encryption tool', 400, 400)
    ; Creates window
    $EditText = GUICtrlCreateEdit('', 5, 5, 380, 350)
    ; Creates main edit
    $InputPass = GUICtrlCreateInput('', 5, 360, 100, 20, 0x21)
    ; Creates the password box with blured/centered input
    $InputLevel = GUICtrlCreateInput(1, 110, 360, 50, 20, 0x2001)
    $UpDownLevel = GUICtrlSetLimit(GUICtrlCreateUpdown($InputLevel), 10, 1)
    ; These two make the level input with the Up|Down ability
    $EncryptButton = GUICtrlCreateButton('Encrypt', 170, 360, 105, 35)
    ; Encryption button
    $DecryptButton = GUICtrlCreateButton('Decrypt', 285, 360, 105, 35)
    ; Decryption button
    GUICtrlCreateLabel('Password', 5, 385)
    GUICtrlCreateLabel('Level', 110, 385)
    ; Simple text labels so you know what is what
    GUISetState()
    ; Shows window

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $EncryptButton
                GUISetState(@SW_DISABLE, $WinMain) ; Stops you from changing anything
                $string = GUICtrlRead($EditText) ; Saves the editbox for later
                GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.') ; Friendly message
                GUICtrlSetData($EditText, _StringEncrypt(1, $string, GUICtrlRead($InputPass), GUICtrlRead($InputLevel))&"over")
                ; Calls the encryption. Sets the data of editbox with the encrypted string
                ; The encryption starts with 1/0 to tell it to encrypt/decrypt
                ; The encryption then has the string that we saved for later from edit box
                ; It then reads the password box & Reads the level box
                GUISetState(@SW_ENABLE, $WinMain) ; This turns the window back on
            Case $DecryptButton
                GUISetState(@SW_DISABLE, $WinMain) ; Stops you from changing anything
                $string = GUICtrlRead($EditText) ; Saves the editbox for later
                GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.') ; Friendly message
                GUICtrlSetData($EditText, _StringEncrypt(0, $string, GUICtrlRead($InputPass), GUICtrlRead($InputLevel))&"over")
                ; Calls the encryption. Sets the data of editbox with the encrypted string
                ; The encryption starts with 1/0 to tell it to encrypt/decrypt
                ; The encryption then has the string that we saved for later from edit box
                ; It then reads the password box & Reads the level box
                GUISetState(@SW_ENABLE, $WinMain) ; This turns the window back on
        EndSwitch
    WEnd ; Continue loop untill window is closed
    Exit
EndFunc   ;==>_Main


[ 本帖最后由 jiataifeng 于 2008-5-20 13:17 编辑 ]
 楼主| 发表于 2008-5-20 10:33:53 | 显示全部楼层
我发现一个规律:
1.在脚本编辑器里运行加密结果为空
2.直接点au3文件运行加密结果正确
3.编译以后运行加密结果为空。
为什么是这样?
 楼主| 发表于 2008-5-20 10:42:51 | 显示全部楼层
知道了,是编码的问题,
编译时使用标准编码就可以了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-16 12:42 , Processed in 0.068252 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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