找回密码
 加入
搜索
查看: 2387|回复: 6

利用MD5实现RegWrite加密及RegRead验证 请大大们帮忙修改

[复制链接]
发表于 2008-10-28 12:30:06 | 显示全部楼层 |阅读模式
利用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 编辑 ]
发表于 2008-10-28 12:36:55 | 显示全部楼层
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
 楼主| 发表于 2008-10-28 12:53:45 | 显示全部楼层
呵呵。谢谢了。又学到点东西。这样就缩减了一行代码。


还有可以修改的地方吗?再等几个小时再改成"已解决"
发表于 2008-10-28 20:20:32 | 显示全部楼层
别的 不知道
发表于 2008-10-28 21:15:02 | 显示全部楼层
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
发表于 2008-10-28 21:55:07 | 显示全部楼层
原帖由 pcbar 于 2008-10-28 21:15 发表
Switch $nMsg
                Case $GUI_EVENT_CLOSE,$ButtonCancel
                        Exit        
                Case $ButtonOk
                        $psw = GUICtrlRead($PasswordEdit)
     ...

我怎么没想到呢。。。。
发表于 2009-1-7 00:46:52 | 显示全部楼层
学习一下。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-19 18:38 , Processed in 0.069959 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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