### Reference Materials
Batch Code for Calculating String Length to Check for Errors
Hehe, see who can figure out the password. The last line is the password. You can delete this line and then execute it to create your own password.
[ Last edited by everest79 on 2006-12-31 at 05:06 AM ]
Batch Code for Calculating String Length to Check for Errors
Hehe, see who can figure out the password. The last line is the password. You can delete this line and then execute it to create your own password.
@ECHO OFF
:TOP
SETLOCAL ENABLEDELAYEDEXPANSION
SET A_X=9
SET B_Y=9
SET C_Z=9
SET BOOT=1
SET BASE=%RANDOM%
CALL :CRY
IF NOT "%CRY%" == "" SET BOOT=0&&CALL :IN
SET DIC=abcdefghijklmnopqrstuvwxyz0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ
CALL :LOS %DIC%
SET DL=%LOS%&&SET /A IDE=%LOS%%%9
IF %LOS% GTR 120 CLS&&ECHO Dictionary too long....&&GOTO END
IF NOT "%IDE%" == "0" ECHO Dictionary setting error&&GOTO END
:inp
IF "%BOOT%" == "1" (
SET MSG0=Start creating new password...&&SET MSG=Please enter new password&&SET MSG9=Creating password.
) ELSE SET MSG0=This document has password protection...&&SET MSG=Please enter&&SET MSG9=Verifying password.
ECHO.
ECHO Password dictionary (password length cannot exceed 40 characters, dictionary length not exceed 120 characters):&&ECHO %DIC%
ECHO Case-sensitive, cannot set characters or spaces other than in the dictionary&&ECHO.
ECHO %MSG0%
:inp1
SET /P PWS="%MSG% PWS:>"
ECHO %PWS%|findstr /r "">nul&&GOTO INP
IF "%BOOT%" == "1" (
SET /P FWS="Enter again PWS:>"
IF NOT "%PWS%" == "!FWS!" (
SET MSG=The two entries are different. Please enter new password
GOTO INP1)
)
SET/P=%MSG9%<nul
CALL :LOS %PWS%
SET PL=%LOS%&&IF %LOS% GTR 40 ECHO Password length cannot exceed 40&&pause&&CLS&&GOTO TOP
SET NPL=%PL%
:calc
IF %NPL% GEQ %DL% SET /A NPL=%NPL%-%DL%&&GOTO CAL
SET /A HPL=%DL%-%NPL%
CALL :CONVERSE 0 %NPL% %NPL% %HPL%
CALL :CONVERSE -%NPL% %NPL% 0 -%NPL%
SET /A HDL=(%DL%-%DL%%%2)/2
SET ADL=!NDIC:~0,%HDL%!&&SET BDL=!NDIC:~%HDL%!&&SET NDIC=
FOR /L %%i IN (0,1,%HDL%) DO SET NDIC=!NDIC!!BDL:~%%i,1!!ADL:~%%i,1!
FOR /L %%z IN (0,1,%C_Z%) DO (
FOR /L %%y IN (0,1,%B_Y%) DO (
FOR /L %%x IN (0,1,%A_X%) DO (
SET /a WD=1%%x%%y%%z%%%DL%
CALL :TEXT !WD!
SET _d_%%x%%y%%z=!TEXT!)
)
SET/P=.<nul)
::set _d_>1.txt&&goto chk
:create
FOR /L %%i IN (0,1,%NNPL%) DO (
FOR /F "tokens=2,3 delims=_=" %%a IN ('SET _d_^|find "=!PWS:~%%i,1!"') DO (
SET /A FF=!FF!+1
SET S!FF!=%%a
)
SET /A CF=%BASE%%%!FF!+1
CALL :OUT !CF!
SET/P=.<nul)
SET NCRY=%BASE%-%JG%
IF "%BOOT%" == "1" (
ECHO.>>"%~dpnx0"&&ECHO SET CRY=%NCRY%>>"%~dpnx0"
ECHO Password set successfully
GOTO END
) ELSE IF "%NCRY%" == "%BASE%-%CRY%" (
ECHO Verification successful&&GOTO NEXT
) ELSE (
ECHO Password error&&pause&&GOTO ENDSET)
GOTO END
:los
SET STR=%1
FOR /L %%i IN (0,1,128) DO if "!STR:~%%i,1!" == "" SET LOS=%%i&&GOTO :EOF
GOTO :EOF
:text
SET TEXT=!NDIC:~%1,1!
GOTO :EOF
:converse
SET /A NNPL=%NPL%-1
SET _tmp2=
SET _tmp1=!DIC:~%1,%2!
FOR /L %%i IN (%NNPL%,-1,0) DO SET _tmp2=!_tmp2!!_tmp1:~%%i,1!
SET NDIC=%_tmp2%!DIC:~%3,%4!
GOTO :EOF
:out
SET JG=!JG!!S%1!&&SET FF=
GOTO :EOF
:in
FOR /F "tokens=1,2 delims=-" %%i IN ("%CRY%") DO SET BASE=%%i&&SET CRY=%%j
CALL :LOS %CRY%
SET HCRY=%LOS%&&SET /A CHK=%LOS%%%3
IF NOT "%CHK%" == "0" ECHO Ciphertext damaged!&&GOTO END
GOTO :EOF
:endset
ENDLOCAL&cls
GOTO TOP
:next
ECHO OK..
GOTO END
:chk
::check label:calc matrix
for /l %%j in (0,1,62) do (
set /a sh=0
for /f "tokens=2 delims==" %%i in (1.txt) do (
if "!DIC:~%%j,1!" == "%%i" set /a sh=!sh!+1)
echo !DIC:~%%j,1! !sh! >>sh.txt)
:end
rem copyright:12232-530502-12000-046006035061035000002030034
PAUSE>nul
EXIT
:cry
::SET /A NDL=%DL%-1
::FOR /L %%i IN (0,1,%NDL%) DO ECHO %PWS%|find "!NDIC:~%%i,1!">nul&&SET BIY=!BIY!!NDIC:~%%i,1!
SET CRY=7304-552511527557551535939937543939547
[ Last edited by everest79 on 2006-12-31 at 05:06 AM ]

