![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-12 10:54 |
共 47,811 主题排行 / 349,897 发帖 / 今日 0 篇 / 48,256 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 关于加密文档的批处理 |
| 可打印版本 2,076 / 7 |
| 第1楼 doshhwa | 发表于 2010-06-19 23:39 |
| 新手上路 发帖 5 积分 5 | |
|
关于加密文档的批处理 现在我想做一个批处理 用来加密文档。
工作方式是这样的: 1.有一个文本文档a.txt 2.经过批处理处理后 生成*.bat *即文件名 能够自定义。 3.用记事本打开此bat看不到里面内容 即看不到文本文档a.txt的内容 4.运行此bat 提示输入批处理时设置的密码。 5.密码通过后在cmd窗口显示文本文档a.txt的内容。 现在不知道如何把txt文件内容插入一个批处理之中。 求高人指教! 我的意图有不明白的地方可以问我。 |
|
| 第2楼 HAT | 发表于 2010-06-20 00:52 |
| 版主 发帖 5,017 积分 9,023 | |
|
你在什么地方看到过这样的批处理?
|
|
| 第3楼 Hanyeguxing | 发表于 2010-06-20 01:53 |
| 银牌会员 发帖 897 积分 1,039 来自 在地狱中仰望天堂 | |
Originally posted by doshhwa at 2010-6-19 23:39: 将a.txt拖到此批处理即开始运行,密码必须为1234567890ABCDEF的任意排列。生成新的批处理为原名加下划如a_bat。运行加密后的批处理生成新的文本为Hanye.txt 例如,文本内容为“寒夜孤星”,密码为“A197D8E5F6C320B4”,生成的批处理如下: @echo off&setlocal enabledelayedexpansion [ Last edited by Hanyeguxing on 2010-6-20 at 02:02 ] |
|
| 第4楼 doshhwa | 发表于 2010-06-20 13:03 |
| 新手上路 发帖 5 积分 5 | |
|
大致的我写出来了。
现在有个问题 : :jm type "%nfile%.bat" | echo @echo off>>"%nfile%.bat" type "%nfile%.bat" | echo title 正在打开加密文档:"file"...>>"%nfile%.bat" type "%nfile%.bat" | echo color a2>>"%nfile%.bat" type "%nfile%.bat" | echo cls>>"%nfile%.bat" type "%nfile%.bat" | echo :begin>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┏ ┓>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 请输入密码。 >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 输入密码后您才能看到文本文档的内容。 >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo set /p mm= 输入密码:>>"%nfile%.bat" type "%nfile%.bat" | echo if not "%mm%"=="%password%" goto mmcw>>"%nfile%.bat" type "%nfile%.bat" | echo goto xuanzefangshi>>"%nfile%.bat" type "%nfile%.bat" | echo :mmcw>>"%nfile%.bat" type "%nfile%.bat" | echo cls>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┏ ┓>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 密码错误!!! 请重新输入! >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 输入密码后您才能看到文本文档的内容。 >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo set /p mm1= 重新输入密码:>>"%nfile%.bat" type "%nfile%.bat" | echo if not "%mm1%"=="%password%" goto mmcw>>"%nfile%.bat" type "%nfile%.bat" | echo :xuanzefangshi type "%nfile%.bat" | echo cls type "%nfile%.bat" | echo echo ┏ ┓>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 请选择文本的打开方式: >>"%nfile%.bat" type "%nfile%.bat" | echo echo 在本窗口中打开。>>"%nfile%.bat" type "%nfile%.bat" | echo echo 生成另一个新文件%nfile%.txt>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo set /p way= 选择方式:>>"%nfile%.bat" type "%nfile%.bat" | echo if "%way%"=="1" goto zhijiedakai>>"%nfile%.bat" type "%nfile%.bat" | echo if "%way%"=="2" goto newtxt>>"%nfile%.bat" type "%nfile%.bat" | echo :zhijiedakai>>"%nfile%.bat" type "%nfile%.bat" | echo cls>>"%nfile%.bat" type %file%>>"%nfile%.bat" type "%nfile%.bat" | echo echo. type "%nfile%.bat" | echo echo =======================end================================>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 如果要复制,请点击右键-标记>>"%nfile%.bat" type "%nfile%.bat" | echo echo 选中所要复制的内容-右键 >>"%nfile%.bat" type "%nfile%.bat" | echo echo 即可复制完成。>>"%nfile%.bat" type "%nfile%.bat" | echo :newtxt>>"%nfile%.bat" type "%nfile%.bat" | echo cls>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┏ ┓>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 文件解密完成!!>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 请查看新生成的文件%nfile%.txt>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo echo 任意键关闭。。。>>"%nfile%.bat" type "%nfile%.bat" | echo pause>nul>>"%nfile%.bat" 上面一段中想要把%file%嵌入%nfile%.bat中 然后运行%nfile%.bat 输入预先设置的密码 选择方式后 %nfile%.bat就能生成一个新的 %file% 或者是在cmd窗口中直接显示%file%的内容 但不知道要怎么做 type "%nfile%.bat" | echo :zhijiedakai>>"%nfile%.bat" type "%nfile%.bat" | echo cls>>"%nfile%.bat" type %file%>>"%nfile%.bat" type "%nfile%.bat" | echo echo. type "%nfile%.bat" | echo echo =======================end================================>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 如果要复制,请点击右键-标记>>"%nfile%.bat" type "%nfile%.bat" | echo echo 选中所要复制的内容-右键 >>"%nfile%.bat" type "%nfile%.bat" | echo echo 即可复制完成。>>"%nfile%.bat" 这一段中 type %file%>>"%nfile%.bat"好像不怎么管用。 [ Last edited by doshhwa on 2010-6-20 at 13:08 ] |
|
| 第5楼 doshhwa | 发表于 2010-06-20 13:34 |
| 新手上路 发帖 5 积分 5 | |
|
现在问题更简单化:
如何把if not "%mm%"=="%password%" goto mmcw 这段 输入%nfile%.bat中。 如果用type "%nfile%.bat" | echo if not "%mm%"=="%password%" goto mmcw>>"%nfile%.bat"的话 输出的东西就是: if not ""=="asdf" goto mmcw (password已在前面定义为asdf所以会显示asdf) 完全的代码是: @echo off set /p file= 文件: set /p nfile= 新文件: set /p password= 密码: :jm type "%nfile%.bat" | echo @echo off>>"%nfile%.bat" type "%nfile%.bat" | echo title 正在打开加密文档:"file"...>>"%nfile%.bat" type "%nfile%.bat" | echo color a2>>"%nfile%.bat" type "%nfile%.bat" | echo cls>>"%nfile%.bat" type "%nfile%.bat" | echo :begin>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┏ ┓>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 请输入密码。 >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 输入密码后您才能看到文本文档的内容。 >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo set /p mm= 输入密码:>>"%nfile%.bat" type "%nfile%.bat" | echo if not "%mm%"=="%password%" goto mmcw>>"%nfile%.bat" type "%nfile%.bat" | echo goto xuanzefangshi>>"%nfile%.bat" type "%nfile%.bat" | echo :mmcw>>"%nfile%.bat" type "%nfile%.bat" | echo cls>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┏ ┓>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 密码错误!!! 请重新输入! >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 输入密码后您才能看到文本文档的内容。 >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo set /p mm= 重新输入密码:>>"%nfile%.bat" type "%nfile%.bat" | echo if not "%mm%"=="%password%" goto mmcw>>"%nfile%.bat" type "%nfile%.bat" | echo :xuanzefangshi type "%nfile%.bat" | echo cls type "%nfile%.bat" | echo echo ┏ ┓>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 请选择文本的打开方式: >>"%nfile%.bat" type "%nfile%.bat" | echo echo [1]在本窗口中打开。>>"%nfile%.bat" type "%nfile%.bat" | echo echo [2]生成另一个新文件%nfile%.txt>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo set /p way= 选择方式:>>"%nfile%.bat" type "%nfile%.bat" | echo if "%way%"=="1" goto zhijiedakai>>"%nfile%.bat" type "%nfile%.bat" | echo if "%way%"=="2" goto newtxt>>"%nfile%.bat" type "%nfile%.bat" | echo :zhijiedakai>>"%nfile%.bat" type "%nfile%.bat" | echo cls>>"%nfile%.bat" type "%nfile%.bat" | type %file%>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo =======================end================================>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 如果要复制,请点击右键-标记>>"%nfile%.bat" type "%nfile%.bat" | echo echo 选中所要复制的内容-右键 >>"%nfile%.bat" type "%nfile%.bat" | echo echo 即可复制完成。>>"%nfile%.bat" type "%nfile%.bat" | echo :newtxt>>"%nfile%.bat" type "%nfile%.bat" | echo cls>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┏ ┓>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 文件解密完成!!>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo 请查看新生成的文件%nfile%.txt>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo echo 任意键关闭。。。>>"%nfile%.bat" type "%nfile%.bat" | echo pause>nul>>"%nfile%.bat" 其中 type "%nfile%.bat" | echo if "%way%"=="1" goto zhijiedakai>>"%nfile%.bat" type "%nfile%.bat" | echo if "%way%"=="2" goto newtxt>>"%nfile%.bat" 也有同样的问题 新生成的文件中没有 %way%... |
|
| 第6楼 Hanyeguxing | 发表于 2010-06-20 14:32 |
| 银牌会员 发帖 897 积分 1,039 来自 在地狱中仰望天堂 | |
|
根本看不到你的代码里有真正加密、解密的过程。
|
|
| 第7楼 doshhwa | 发表于 2010-06-20 14:54 |
| 新手上路 发帖 5 积分 5 | |
|
不是 加密解密的段还没加进去 。
不知道怎么把 if not "%mm%"=="%password%" goto mmcw 这段输入%nfile%.bat中。 如果用type "%nfile%.bat" | echo if not "%mm%"=="%password%" goto mmcw>>"%nfile%.bat"的话 输出的东西就是: if not ""=="asdf" goto mmcw (password已在前面定义为asdf所以会显示asdf) |
|
| 第8楼 acaigg | 发表于 2010-12-28 10:32 |
| 初级用户 发帖 92 积分 115 | |
|
学习一下
|
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |