这样是否能再提速点
加密:- @echo off&setlocal enabledelayedexpansion
- set "s1=我想他肯定知道这个地方有段好难走的路"
- set "s2=当敌人冲过来后你就拉响前面的警报行"
- for /l %%a in (1,1,2) do (
- set /a "m=8189,x=0,l=0"
- for /l %%b in (1,1,14) do (
- set /a "l=(m+x)/2"
- for %%i in (!l!) do if "!s%%a:~%%i!" equ "" (set /a m=l) else set /a x=l
- )
- set /a "_l%%a=l"
- for /l %%b in (0,1,!l!) do set str=!str! !s%%a:~%%b,1!
- )
- for /f "tokens=1-18 delims=:-" %%a in ('findstr /nr "%str%" homebooka.txt') do (
- set /a a=%%a/14+1,n=-1
- for %%v in (%%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%r) do (
- set /a "n+=1,c=n%%21/4+1,d=n%%4+1"
- if "!str:%%v=!" neq "!str!" if not defined %%v set "%%v=!a!-%%b-!c!-!d!"
- )
- )
- for /l %%a in (1,1,2) do (
- set "var="
- for /l %%b in (0,1,!_l%%a!) do for %%c in ("!s%%a:~%%b,1!") do set "var=!var! !%%~c!"
- echo 原文:!s%%a!
- echo 密文:!var!
- )
- pause
复制代码 解密:- @echo off&setlocal enabledelayedexpansion
- set "s1=17-5-5-1 8-2-2-4 17-10-4-4 9-8-3-1 3-2-5-3 21-7-1-2 15-9-1-3"
- set "s2=24-5-3-1 10-5-3-4 28-5-1-2 3-2-5-3 21-7-1-2 7-10-4-4 25-5-4-4 32-1-5-3 31-3-5-3 25-7-1-2 12-2-4-1 3-2-5-1"
- for /l %%a in (1,1,2) do (
- for %%b in (!s%%a!) do (
- for /f "tokens=1-4 delims=- " %%i in ("%%b") do (
- set %%i-%%j=i&set "%%b=j"
- )))
- for /f "tokens=1-18 delims=:- " %%a in ('findstr /nr ":" homebooka.txt') do (
- set /a a=%%a/14+1,n=-1
- if defined !a!-%%b (
- for %%v in (%%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%r) do (
- set /a "n+=1,c=n%%21/4+1,d=n%%4+1"
- if defined !a!-%%b-!c!-!d! set "!a!-%%b-!c!-!d!=%%v"
- )
- )
- )
- for /l %%a in (1,1,2) do (
- set "var="
- for %%b in (!s%%a!) do set "var=!var!!%%b!"
- echo 原文:!s%%a!
- echo 密文:!var!
- )
- pause
复制代码
|