标题: [其他] 批处理如何让输入的字符即时显示为星号 [打印本页]
作者: bean 时间: 2009-4-21 09:44 标题: 批处理如何让输入的字符即时显示为星号
如题,批处理输入密码但显示星号的代码之批处理应用版
http://bbs.bathome.net/thread-2130-1-1.html
这篇文章有人可以给我讲解一下吗?像,如果我直接要一段星号显示密码的代码,要怎么改过来.我主要是想用来加密批处理的时候,让输入的字符显示为星号。(不显示的不要,不借助第三方软件)
[ 本帖最后由 bean 于 2009-4-21 10:06 编辑 ]
作者: Batcher 时间: 2009-4-21 13:15
- @echo off
- set RealPwd=Batcher
- >"%temp%\Star1.tmp" (echo e0100 BB 00 B8 8E C3 BF 00 00 BE 00 00 B4 00 CD 16 80
- echo e0110 FC 0E 75 0E 83 FE 00 74 F2 4E 4F 4F 26 C6 05 20
- echo e0120 EB E9 80 FC 1C 74 1C 3C 20 72 E0 26 C6 05 2A 8C
- echo e0130 C2 BB 00 00 8E C3 26 88 84 01 02 8E C2 83 C7 02
- echo e0140 46 EB C8 BB 00 00 8E C3 8B C6 26 A2 00 02 B8 00
- echo e0150 4C CD 21
- echo rcx
- echo 53
- echo n %temp%\Star2.tmp
- echo w
- echo q
- )
- debug<"%temp%\Star1.tmp">nul
- copy /b /y "%temp%\Star2.tmp" "%temp%\Star.exe">nul
- echo Enter password (not longer than 32).
- pause
- cls
- "%temp%\Star.exe"
- echo exit|cmd /kprompt d20:0 20$_q$_|debug>"%temp%\Star.tmp"
- for /f "usebackq skip=2 tokens=*" %%a in ("%temp%\Star.tmp") do (
- set t=%%a
- call set t=%%t:~61,16%%
- call set s=%%s%%%%t%%
- )
- for /f "usebackq skip=2 tokens=2" %%a in ("%temp%\Star.tmp") do (
- set /a l=0x%%a
- goto :CommPass
- )
- :CommPass
- call set InputPwd=%%s:~1,%l%%%
- echo.
- if "%InputPwd%" equ "%RealPwd%" (
- echo Correct password.
- ) else (
- echo Incorrect password.
- )
- pause
复制代码
作者: bean 时间: 2009-4-22 11:38 标题: 批处理输入密码变为星号(可自己设置密码)
- @echo off
- ::此代码变量名有:mmyz,ipt,do,err,w,t 请注意不要使用重复的变量名
- ::密码是"123",位于12行处
- ::小饭豆作品QQ156780221
- color 0a
- :mmyz
- cls
- color 0a
- title 密码验证 BY小饭豆作品
- echo 请按任意键后 输入密码
- pause>nul
- call :ipt %0 pd
- if /i "%pd%"=="123" (goto do) else goto err
-
-
- :do
- color 0a
- cls
- title 密码正确 BY小饭豆作品
-
- echo.
- echo.密码输入正确
- echo.
- pause>nul
- exit
-
- :err
- color 0a
- cls
- title 密码错误 BY小饭豆作品
- echo.
- echo.密码错误,按任意键返回重新输入!
- echo.
- pause>nul
- goto mmyz
-
-
-
- :ipt
- pushd %tmp%&set lines=0&set f=%1&set p=%2
- for /f "usebackq delims=" %%a in (%f%) do if "%%a" neq "::for debug:" (set/a lines+=1) else (goto :w)
- :w
- set/a lines+=1
- more +%lines% %f%|debug>nul&move t "t.com"
- cls
- t
- echo exit|cmd /kprompt d20:0 20$_q$_|debug>t
- for /f "skip=2 tokens=*" %%a in (t) do set t=%%a&call set t=%%t:~61,16%%&call set s=%%s%%%%t%%
- for /f "skip=2 tokens=2" %%a in (t) do set/a l=0x%%a&goto :t
- :t
- call set %p%=%%s:~1,%l%%%&set "lines="&set "f="&set "p="&set "t="&set "s="&set "l="
- del t t.com&popd&>nul (chcp 437&graftabl 936)&goto :eof
- ::for debug:
- e0100 BB 00 B8 8E C3 BF 00 00 BE 00 00 B4 00 CD 16 80
- e0110 FC 0E 75 0E 83 FE 00 74 F2 4E 4F 4F 26 C6 05 20
- e0120 EB E9 80 FC 1C 74 1C 3C 20 72 E0 26 C6 05 2A 8C
- e0130 C2 BB 00 00 8E C3 26 88 84 01 02 8E C2 83 C7 02
- e0140 46 EB C8 BB 00 00 8E C3 8B C6 26 A2 00 02 B8 00
- e0150 4C CD 21
- rcx
- 53
- n t
- w
- q
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |