汇编写的密码获取验证程序

密码申请验证程序

.model small
.stack
.data
msgwel db 'Welcome to Registration software!',0dh,0ah,'$'
msgshow db 0dh,0ah,'**1.Get the password**',0dh,0ah,'**2.Verity the password**',0dh,0ah,'**3.Exit**',0dh,0ah,'$'
msgPutName db 'Please input your name(no more than four):',0dh,0ah,'$'
msgPutCode db 0dh,0ah,'Please input your code:',0dh,0ah,'$'
msgOK db 0dh,0ah,'Register Success!',0dh,0ah,'$'
msgError db 0dh,0ah,'Register Error!',0dh,0ah,'$'
msgpw db 0dh,0ah,'your password is:$'
userName db 5
nNum          db ?
                   db 5 dup (?)
userCode db 5
cNum         db ?
                  db 5 dup (?)
nCode        dw ?
iCode         dw ?
.code
.startup
         mov dx,offset msgwel   ; 显示欢迎信息
         mov ah,9
         int 21h
show:    mov dx,offset msgshow
         mov ah,9
         int 21h
         mov ah,1
         int 21h
         cmp al,'3'
         je quit
         cmp al,'1'
         je getpw
         cmp al,'2'
         je testpw
         jmp show
 
getpw:      mov ah,9                ;获取密码
        mov dx,offset msgPutName
        int 21H
        mov ah,0AH
        mov dx,offset userName
        int 21H
        mov ah,9
         mov dx,offset msgpw
         int 21h
         call password
        mov cl,4
         mov al,bh
        shr al,cl
        call htoasc
        mov al,bh
        call htoasc
        mov al,bl
        shr al,cl
        call htoasc
        mov al,bl
        call htoasc
        jmp show
 
testpw:mov ah,9                ; 验证密码
          mov dx,offset msgPutName
          int 21H
          mov ah,0AH
          mov dx,offset userName
          int 21H
         
          mov ah,9
          mov dx,offset msgPutCode
          int 21H
          mov ah,0AH
          mov dx,offset userCode
          int 21H
          call password
          mov cx,0
          mov cl,cNum
          ;cmp cx,0
          ;jz quit
          mov si,offset userCode
          add si,2
          xor ax,ax
liCode:    mov di,10        
          mul di
          mov dl,[si]
          sub dl,30H
          add al,dl
          adc ah,0
          inc si
         loop liCode
         cmp ax,ncode
          jz ok
error: mov ah,9
        mov dx,offset msgError
        int 21H
        jmp show
 
OK:     mov ah,9
       mov dx,offset msgOK
       int 21H  
       jmp show
quit:
.exit 0
 
password proc             ;根据用户名生成密码
          mov cx,0
          mov cl,byte ptr nNum
          ;cmp cx,0
          ;jz quit
          mov si,offset userName
          add si,2
          mov bx,0
          mov ah,0
lnCode:    mov al,byte ptr [si]
          add bx,ax
          inc si
          loop lnCode
          mov ax,10H
          mul bx
          mov nCode,ax
          mov bx,ax
          ret
password endp
 
htoasc    proc                  ;显示密码
         and al,0fh
          or al,30h
          cmp al,39h
          jbe htoend
         add al,7
htoend: mov dl,al
         mov ah,02h
         int 21h
         ret
htoasc endp
end
 
程序功能:
用户输入姓名获得密码,密码为十六进制,转化为十进制后,就可以通过验证注册。
举例:
运行程序后可见:
         Welcome to Registration software!
         **1.Get the password**
**2.Verity the password**
**3.Exit**
输入1,可以获取密码:
        Please input your name(no more than four):
输入姓名:abcd
your password is:18A0
这样获取密码为:18A0,这是十六进制,将其转化为十进制为6304。
输入2,进行密码验证:
Please input your name(no more than four):
输入姓名:abcd
         Please input your code:
输入:6304
显示:Register Success!
输入其他则:Register Error!
输入3,退出。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值