以下内容无关紧要,看不看无所谓
差不多用了六七个小时的时候完成的
ping -n %ddsj% -w 500 10.29.253.221>nul
关键是到这里的时候出现了一点小问题,在XP上运行时间可以从秒的00秒和30秒开始运行,但是在win8.1上运行时秒上的时间问题会从9秒和39秒开始,不知为何。
最后换成了choice /t %ddsj% /d y /n>nul才搞定的- @echo off
- rem 本代码是@szl1123原创
- rem 2014年6月26日@YuZhou
- title 随机密码 by szl123
- mode con: cols=55 lines=11
- color 0A
- if "%~n0f"=="byszl1123f" goto xsmm
- :start
- cls
- set mim=
- echo.
- echo.
- echo.
- set /p mim=请输入密码:
- if "/%mim%/"=="//" goto start
- goto sjjs
- :sjjs
- cls
- for /f "tokens=2,*" %%i in ('reg query "HKCU\Control Panel\International" /v "sShortDate"') do (
- set ysdate=%%j
- )
- reg add "HKCU\Control Panel\International" /v "sShortDate" /t reg_sz /d "yyyy-MM-dd-dddd" /f>nul
- set nian=%date:~0,4%
- set yue=%date:~5,2%
-
- if %yue:~0,1%==0 set yue=%yue:~1,1%
- set ri=%date:~8,2%
- if %ri:~0,1%==0 set ri=%ri:~1,1%
- reg add "HKCU\Control Panel\International" /v "sShortDate" /t reg_sz /d "%ysdate%" /f>nul
- set sdtime=%time%
- set shi=%sdtime:~0,2%
- if %shi:~0,1%==0 set shi=%shi:~1,1%>>0.txt
- if "%shi%"=="0" set shi=%ri%*%yue%>>0.txt
- set fen=%sdtime:~3,2%
- if %fen:~0,1%==0 set fen=%fen:~1,1%
- if "%fen%"=="0" set fen=%ri%*%yue%+%ri%
- set miao=%sdtime:~6,2%
- if %miao:~0,1%==0 set miao=%miao:~1,1%
- if %miao% leq 29 set /a ddsj=29-%miao%+1
- if %miao% geq 30 set /a ddsj=59-%miao%+1
- set /a bmiao=(%fen%+21)*(%shi%+6)+(%fen%+4)*%yue%
- if %miao% geq 30 set /a bmiao=(%nian%-%fen%*%ri%)*%fen%
- set /a mima=%nian%*(%shi%+%bmiao%)*(%fen%+%bmiao%)*%ri%+(%bmiao%+%shi%+%yue%)*%fen%
- set /a mima1=%nian%*(%shi%+%bmiao%)*%fen%*%fen%*%ri%+(%bmiao%+%shi%+%yue%)*%fen%*%fen%*%bmiao%
- set /a mima2=%nian%*(%shi%+%bmiao%)*(%fen%+%bmiao%*%ri%)+(%bmiao%*%shi%+%yue%)*%fen%
- set /a mima3=%nian%*(%shi%+%bmiao%)*(%fen%+%bmiao%)*%ri%*(%bmiao%+%shi%+%yue%)+%fen%
- set /a mima4=%fen%*%bmiao%*(%shi%+%nian%)+(%fen%+%fen%*%bmiao%)*%ri%+(%bmiao%*%shi%*%yue%)*%fen%
- set /a mima5=%fen%*(%shi%+%bmiao%)*(%nian%*%bmiao%)*%ri%+(%bmiao%*%shi%+%yue%)*%fen%
- set /a mima6=%fen%*(%shi%+%bmiao%)*(%fen%+%ri%)*%bmiao%+(%bmiao%+%shi%+%yue%)*%nian%
- set /a mima7=%nian%*(%shi%+%bmiao%)*(%ri%+%bmiao%)*%fen%+(%bmiao%+%shi%+%yue%)*%fen%
- set /a mima8=%nian%*(%shi%+%bmiao%)*(%fen%+%bmiao%)*%ri%*%fen%+(%bmiao%+%shi%+%yue%)*%fen%
- set /a mima9=%nian%*(%shi%+%bmiao%)*%fen%*(%fen%+%bmiao%)*%ri%+(%bmiao%+%shi%+%yue%)*%fen%*%fen%
- set /a mima10=%fen%*%fen%%nian%*(%shi%+%bmiao%)*(%fen%+%fen%)*%ri%+%ri%*(%bmiao%+%fen%+%shi%+%yue%)*%fen%
- set /a mima11=%nian%*(%fen%+%bmiao%)*(%fen%+%bmiao%)*%fen%+(%bmiao%+%shi%+%yue%)*%fen%
- set /a mima12=%nian%*(%shi%+%fen%)*(%fen%*%bmiao%)*%fen%+(%bmiao%+%shi%*%yue%)*%fen%
- set /a mima13=%nian%*(%shi%+%bmiao%)*(%fen%*%ri%+%bmiao%)*(%ri%+%fen%)+(%bmiao%*%shi%+%fen%)*%fen%
- set /a mima14=%nian%*(%shi%+%bmiao%)*%ri%*(%fen%+%bmiao%)*%fen%*%fen%+(%bmiao%+%shi%+%yue%)*%fen%*%fen%
- set yzmm=0
- if "%mim%"=="%mima:~-8%" set yzmm=1
- if "%mim%"=="%mima1:~-8%" set yzmm=1
- if "%mim%"=="%mima2:~-8%" set yzmm=1
- if "%mim%"=="%mima3:~-8%" set yzmm=1
- if "%mim%"=="%mima4:~-8%" set yzmm=1
- if "%mim%"=="%mima5:~-8%" set yzmm=1
- if "%mim%"=="%mima6:~-8%" set yzmm=1
- if "%mim%"=="%mima7:~-8%" set yzmm=1
- if "%mim%"=="%mima8:~-8%" set yzmm=1
- if "%mim%"=="%mima9:~-8%" set yzmm=1
- if "%mim%"=="%mima10:~-8%" set yzmm=1
- if "%mim%"=="%mima11:~-8%" set yzmm=1
- if "%mim%"=="%mima12:~-8%" set yzmm=1
- if "%mim%"=="%mima13:~-8%" set yzmm=1
- if "%mim%"=="%mima14:~-8%" set yzmm=1
-
- if "%yzmm%"=="1" goto ok
- goto error
-
- :xsmm
- cls
- for /f "tokens=2,*" %%i in ('reg query "HKCU\Control Panel\International" /v "sShortDate"') do (
- set ysdate=%%j
- )
- reg add "HKCU\Control Panel\International" /v "sShortDate" /t reg_sz /d "yyyy-MM-dd-dddd" /f>nul
- set nian=%date:~0,4%
- set yue=%date:~5,2%
-
- if %yue:~0,1%==0 set yue=%yue:~1,1%
- set ri=%date:~8,2%
- if %ri:~0,1%==0 set ri=%ri:~1,1%
- reg add "HKCU\Control Panel\International" /v "sShortDate" /t reg_sz /d "%ysdate%" /f>nul
- set sdtime=%time%
- set shi=%sdtime:~0,2%
- if %shi:~0,1%==0 set shi=%shi:~1,1%>>0.txt
- if "%shi%"=="0" set shi=%ri%*%yue%>>0.txt
- set fen=%sdtime:~3,2%
- if %fen:~0,1%==0 set fen=%fen:~1,1%
- if "%fen%"=="0" set fen=%ri%*%yue%+%ri%
- set miao=%sdtime:~6,2%
- if %miao:~0,1%==0 set miao=%miao:~1,1%
- if %miao% leq 29 set /a ddsj=29-%miao%+1
- if %miao% geq 30 set /a ddsj=59-%miao%+1
- set /a bmiao=(%fen%+21)*(%shi%+6)+(%fen%+4)*%yue%
- if %miao% geq 30 set /a bmiao=(%nian%-%fen%*%ri%)*%fen%
- set /a mima=%nian%*(%shi%+%bmiao%)*(%fen%+%bmiao%)*%ri%+(%bmiao%+%shi%+%yue%)*%fen%
- set /a mima1=%nian%*(%shi%+%bmiao%)*%fen%*%fen%*%ri%+(%bmiao%+%shi%+%yue%)*%fen%*%fen%*%bmiao%
- set /a mima2=%nian%*(%shi%+%bmiao%)*(%fen%+%bmiao%*%ri%)+(%bmiao%*%shi%+%yue%)*%fen%
- set /a mima3=%nian%*(%shi%+%bmiao%)*(%fen%+%bmiao%)*%ri%*(%bmiao%+%shi%+%yue%)+%fen%
- set /a mima4=%fen%*%bmiao%*(%shi%+%nian%)+(%fen%+%fen%*%bmiao%)*%ri%+(%bmiao%*%shi%*%yue%)*%fen%
- set /a mima5=%fen%*(%shi%+%bmiao%)*(%nian%*%bmiao%)*%ri%+(%bmiao%*%shi%+%yue%)*%fen%
- set /a mima6=%fen%*(%shi%+%bmiao%)*(%fen%+%ri%)*%bmiao%+(%bmiao%+%shi%+%yue%)*%nian%
- set /a mima7=%nian%*(%shi%+%bmiao%)*(%ri%+%bmiao%)*%fen%+(%bmiao%+%shi%+%yue%)*%fen%
- set /a mima8=%nian%*(%shi%+%bmiao%)*(%fen%+%bmiao%)*%ri%*%fen%+(%bmiao%+%shi%+%yue%)*%fen%
- set /a mima9=%nian%*(%shi%+%bmiao%)*%fen%*(%fen%+%bmiao%)*%ri%+(%bmiao%+%shi%+%yue%)*%fen%*%fen%
- set /a mima10=%fen%*%fen%%nian%*(%shi%+%bmiao%)*(%fen%+%fen%)*%ri%+%ri%*(%bmiao%+%fen%+%shi%+%yue%)*%fen%
- set /a mima11=%nian%*(%fen%+%bmiao%)*(%fen%+%bmiao%)*%fen%+(%bmiao%+%shi%+%yue%)*%fen%
- set /a mima12=%nian%*(%shi%+%fen%)*(%fen%*%bmiao%)*%fen%+(%bmiao%+%shi%*%yue%)*%fen%
- set /a mima13=%nian%*(%shi%+%bmiao%)*(%fen%*%ri%+%bmiao%)*(%ri%+%fen%)+(%bmiao%*%shi%+%fen%)*%fen%
- set /a mima14=%nian%*(%shi%+%bmiao%)*%ri%*(%fen%+%bmiao%)*%fen%*%fen%+(%bmiao%+%shi%+%yue%)*%fen%*%fen%
- echo.
- echo.
- echo. 密码%ddsj%秒后自动更新,每次更新15个。
- echo.
- echo. 如果不使用请直接关闭程序。
- echo.
- echo 密码是:%mima:~-8% ^| %mima1:~-8% ^| %mima2:~-8%
- echo %mima3:~-8% ^| %mima4:~-8% ^| %mima5:~-8%
- echo %mima6:~-8% ^| %mima7:~-8% ^| %mima8:~-8%
- echo %mima9:~-8% ^| %mima10:~-8% ^| %mima11:~-8%
- echo %mima12:~-8% ^| %mima13:~-8% ^| %mima14:~-8%
- choice /t %ddsj% /d y /n>nul
- goto xsmm
-
-
- :ok
- cls
- echo.
- echo.
- echo. 恭喜您输入的密码:“%mim%”正确
- echo.
- echo.
- msg * /time:4 /w "恭喜您输入的密码:“%mim%”正确"
- pause
- goto start
-
- :error
-
- echo.
- echo.
- echo. 不好意思您输入的密码:“%mim%”错误
- echo.
- echo.
- msg * /time:4 /w "不好意思您输入的密码:“%mim%”错误"
- goto start
复制代码
源文件下载。
作者: CrLf 时间: 2014-6-26 22:47
提个小建议,可能可以借鉴支付宝的动态密码那样,每三十秒一周期依次产生若干密码,比如三十个,寿命为一个周期,这三十个密码在各自的周期内都是正确的
这样用户每次都有整整三十秒的时间来输入密码,手残党就不需要因为到了 27 秒来不及打字而等待下一个周期,所依赖的时间同步精度也低了许多
作者: szl1123 时间: 2014-6-26 23:13
回复 2# CrLf
那就是在就算的时候多设定几个值,明天试一下。
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |