利用MD5实现RegWrite加密及RegRead验证 请大大们帮忙修改
利用MD5实现RegWrite加密及RegRead验证 加以密码对话框的使用 因为是初学者 所以请大大帮忙修改一下 看能不能缩减代码#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <md5.au3>
$mm1 = md5("admin")
$mm2 = RegWrite("HKLM\Software\set", "password","reg_sz",$mm1)
$Form2 = GUICreate("密码对话框", 251, 100, -1, -1)
GUISetIcon("D:\autoit3\Aut2Exe\Icons\tc.ico")
$PasswordEdit = GUICtrlCreateInput("", 8, 32, 233, 21, $ES_PASSWORD)
GUICtrlSetLimit(-1, 18)
$ButtonOk = GUICtrlCreateButton("确定(&O)", 86, 64, 75, 25, 0)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$ButtonCancel = GUICtrlCreateButton("取消(&C)", 167, 64, 75, 25, 0)
$EnterPassLabel = GUICtrlCreateLabel("请输入密码:", 8, 12, 76, 17)
$mm = RegRead("HKLM\Software\set", "password")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ButtonCancel
Exit
Case $ButtonOk
$psw = GUICtrlRead($PasswordEdit)
If md5($psw) <> $mm Then
MsgBox(16,"密码错误",'请重新输入密码')
ControlSetText("","",$PasswordEdit,"")
EndIf
If md5($psw) = $mm Then
ExitLoop
EndIf
EndSwitch
WEnd
MsgBox(64,"通过","验证通过")
[ 本帖最后由 gs008970 于 2008-10-28 14:23 编辑 ] If md5($psw) <> $mm Then
MsgBox(16,"密码错误",'请重新输入密码')
ControlSetText("","",$PasswordEdit,"")
EndIf
If md5($psw) = $mm Then
ExitLoop
EndIf
这段不就是IF ELSE吗
If md5($psw) <> $mm Then
MsgBox(16, "密码错误", '请重新输入密码')
ControlSetText("", "", $PasswordEdit, "")
Else
ExitLoop
EndIf 呵呵。谢谢了。又学到点东西。这样就缩减了一行代码。
还有可以修改的地方吗?再等几个小时再改成"已解决" 别的 不知道 Switch $nMsg
Case $GUI_EVENT_CLOSE,$ButtonCancel
Exit
Case $ButtonOk
$psw = GUICtrlRead($PasswordEdit)
If md5($psw) <> $mm Then
MsgBox(16,"密码错误",'请重新输入密码')
ControlSetText("","",$PasswordEdit,"")
Else
ExitLoop
EndIf
EndSwitch 原帖由 pcbar 于 2008-10-28 21:15 发表 http://www.autoitx.com/images/common/back.gif
Switch $nMsg
Case $GUI_EVENT_CLOSE,$ButtonCancel
Exit
Case $ButtonOk
$psw = GUICtrlRead($PasswordEdit)
...
我怎么没想到呢。。。。 学习一下。
页:
[1]