『第
3 楼』:
Quote: | Originally posted by doshhwa at 2010-6-19 23:39:
现在我想做一个批处理 用来加密文档。
工作方式是这样的:
1.有一个文本文档a.txt
2.经过批处理处理后 生成*.bat *即文件名 能够自定义。
3.用记事本打开此bat看不到里面内容 即看不到文本文档a.txt的内容
4.运行此bat 提示输入批处理时设置的密码。
5.密码通过后在cmd窗口显示文本文档a.txt的内容。
现在不知道如何把txt文件内容插入一个批处理之中。
求高人指教!
我的意图有不明白的地方可以问我。 |
|
将a.txt拖到此批处理即开始运行,密码必须为1234567890ABCDEF的任意排列。生成新的批处理为原名加下划如a_bat。运行加密后的批处理生成新的文本为Hanye.txt
@echo off&setlocal ENABLEDELAYEDEXPANSION
cd/d "%~dp0">nul
if %~z1 gtr 65280 echo.文件大小超出范围而出错&pause&exit
copy/b "%~1" $tmp$>nul
set/a s=%~z1+255
set q=123456789ABCDEF0
set/p p=请设置密码:
for /l %%a in (0,1,15) do set "#!p:~%%a,1!=!q:~%%a,1!"
call:n %s%
(for /f "delims=" %%a in ('more +29^<%~fs0') do echo.%%a)>"%~n1_.bat"
(for /f "eol=- skip=1 delims=" %%a in ('^(echo d100,%s%^&echo q^)^|debug $tmp$^&^&del $tmp$') do (
set a=%%a&set a=!a:-= !
set/p=e!a:~5,6!<nul&set a=!a:~11,47!
for /l %%b in (0,1,46) do if "!a:~%%b,1!"==" " (set/p= <nul) else for %%c in (!a:~%%b^,1!) do set/p=!#%%c!<nul
echo.
))>>"%~n1_.bat"
graftabl 936 >nul
call:n %~z1
(for %%a in (rcx %s% nHanye.txt w q) do echo.%%a)>>"%~n1_.bat"
exit
:n
set n=%1&set s=
:m
set/a m=%n%%%16-1
set/a n/=16
set m=!q:~%m%,1!
set s=%m%%s%
if "%n%" neq "0" goto:m
goto:eof
@echo off&setlocal enabledelayedexpansion
set q=!q!
set/p p=请输入密码:
for /l %%a in (0,1,15) do set "#^!q:~%%a,1^!=^!p:~%%a,1^!"
(for /f "delims=" %%a in ('more +15^<%~fs0') do (
set k=%%a&if not "^!k:~0,1^!"=="e" (echo.%%a) else (
set/p=^!k:~0,7^!<nul&set k=^!k:~7^!
for /l %%b in (0,1,46) do if "^!k:~%%b,1^!"==" " (set/p= <nul) else for %%c in (^!k:~%%b^^,1^!) do set/p=^!#%%c^!<nul
echo.
)
))>$tmp$
debug<$tmp$>nul
del /q $tmp$
graftabl 936 >nul
start "" Hanye.txt&exit 例如,文本内容为“寒夜孤星”,密码为“A197D8E5F6C320B4”,生成的批处理如下:
Quote: | @echo off&setlocal enabledelayedexpansion
set q=123456789ABCDEF0
set/p p=请输入密码:
for /l %%a in (0,1,15) do set "#!q:~%%a,1!=!p:~%%a,1!"
(for /f "delims=" %%a in ('more +15^<%~fs0') do (
set k=%%a&if not "!k:~0,1!"=="e" (echo.%%a) else (
set/p=!k:~0,7!<nul&set k=!k:~7!
for /l %%b in (0,1,46) do if "!k:~%%b,1!"==" " (set/p= <nul) else for %%c in (!k:~%%b^,1!) do set/p=!#%%c!<nul
echo.
)
))>$tmp$
debug<$tmp$>nul
del /q $tmp$
graftabl 936 >nul
start "" Hanye.txt&exit
e0100 F1 17 5D F3 F3 BD 5E B4
rcx
8
nHanye.txt
w
q |
|
[ Last edited by Hanyeguxing on 2010-6-20 at 02:02 ]
|