用汇编语言 密码验证代码怎么写
发布网友
发布时间:2023-04-10 16:05
我来回答
共2个回答
热心网友
时间:2023-09-16 12:02
;密码验证代码
;
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
start: MOV AX,CODE
MOV DS,AX
cld
AGAIN: MOV AX,3
INT 10H
lea dx,MENU ;主菜单
mov ah,9
int 21h
input:
mov ah,0
int 16h
cmp al,'1'
jnz cp2
call sub01 ;输入一个字符串
jmp AGAIN
cp2:cmp al,'2'
jnz cp3
call sub02 ;字符串左右移动
jc exit
jmp AGAIN ;返回到主菜单
cp3:cmp al,'3' ;返回DOS
jnz input
exit:
lea dx,MESG
mov ah,9
int 21h
mov ah,1
int 21h
MOV AH,4CH
INT 21H
sub01:
mov ax,3
int 10h
lea dx,tips
mov ah,9
int 21h
lea dx,msg1
mov ah,0ah
int 21h ;输入一个字符串
mov ax,0e0dh
int 10h
mov al,0ah
int 10h
ret
sub02:
mov ax,3
int 10h
clc
push ds
pop es
mov bp,3
sss:
lea dx,Pass
mov ah,9
int 21h
lea dx,msg2
mov ah,0ah
int 21h
lea si,buf1
lea di,buf2
mov ch,0
mov cl,msg1+1
cmp cl,msg2+1
jnz cuowu
repz cmpsb
jcxz right
cuowu:
lea dx,no
mov ah,9
int 21h
dec bp
jnz sss
stc
jmp ok
right:
lea dx,yes
mov ah,9
int 21h
ok:
mov ah,1
int 21h
ret
MENU DB 5 DUP(0AH)
DB 31 DUP(' '),'MAIN MENU',0DH,0AH
DB 25 DUP(' '),201,21 DUP(205),187,0DH,0AH
DB 25 DUP(' '),186,' 1.Shuru Mima',8 p (20h),186,0DH,0AH
DB 25 DUP(' '),186,' 2.Jiaoyan Mima',6 p (20h),186,0DH,0AH
DB 25 DUP(' '),186,' 3.Return to DOS ... ',186,0DH,0AH
DB 25 DUP(' '),200,21 DUP(205),188,0DH,0AH
DB 28 DUP(' '),'Choice(1,2,3):$'
MESG DB 0dh,0ah,0dh,0ah,9,'Press any key to exit ...$'
Pass db 0dh,0ah,9,'Enter your password: $'
yes db 0dh,0ah,9,'password correct$'
no db 0dh,0ah,9,'password error$'
tips db 0dh,0ah,9,'Input a string: $'
msg1 db 255,0
buf1 db 255 p(0)
msg2 db 255,0
buf2 db 255 p(0)
CODE ENDS
END start
参考资料:http://zhidao.baidu.com/question/131465722.html
热心网友
时间:2023-09-16 12:02
用access数据库建立一个EmployeeData.mdb数据(数据库名字可自定,但下面的代码也得相应就修改)
'再建立一个表名为:userinfo
'其中字段为如下:
listid(主键) 自动编号
UserId 文本
Userpawd 文本
-----------------------------------------------------------------------------------
'定义一个公用模块
Mole Mole1
Public Ds As New DataSet
Public sqlstr As String
Private path As String = Application.StartupPath & "\EmployeeData.mdb"
Public conn As New System.data.oledb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & path)
End Mole
------------------------------------------------------------------------------------'在窗体中调用
Imports System.Data.OleDb
-------双击登录按钮添加代码---------------------------------------------------------
Private Sub ButLand_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButLand.Click
Dim User As String
Dim Password As String
'定义两个变量
Dim i As Integer
Dim frmmain As New FrmMain
'给 User,Password 附值
User = Me.TxtUserid.Text.Trim
Password = Me.TxtPawd.Text.Trim
Try
sqlstr = "select * from userinfo "
Dim da As New OleDbDataAdapter(sqlstr, conn)
Dim ds As New DataSet
Dim row As DataRow
da.Fill(ds, "userinfo")
Dim dt As DataTable = ds.Tables("userinfo")
Dim rows As DataRow() = dt.Select("UserId='" & User & "'")
row = rows(0)
If User <> "" And Password <> "" And User = row.Item("UserId") And Password = row.Item("Userpawd") Then
i = MsgBox("恭喜你已成功登陆", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "系统消息")
frmmain.Show()
Me.Finalize()
Else
i = MsgBox("密码和账号不符,请重试,并检查该账号是否存在。", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "系统登录失败")
TxtPawd.Text = ""
End If
Static n As Integer
n = n + 1
If n = 4 Then
i = MsgBox("对不起你不是该用户!", MsgBoxStyle.Information + MsgBoxStyle.MsgBoxHelp, "系统消息")
Close()
End If
Catch
MsgBox(Err.Description)
Exit Sub
End Try
End Sub
---------------------------------------------------------------------------------------------
仅供参考,~_~
参考资料:http://topic.csdn.net/t/20061224/21/5252968.html