![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-12 11:47 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » Batch processing about encrypted documents |
| Printable Version 2,078 / 7 |
| Floor1 doshhwa | Posted 2010-06-19 23:39 |
| 新手上路 Posts 5 Credits 5 | |
|
Now I want to make a batch script to encrypt a document.
The working method is like this: 1. There is a text document a.txt 2. After processing by the batch script, generate *.bat * that is the file name and can be customized. 3. When opening this bat with Notepad, you can't see the content inside, that is, you can't see the content of the text document a.txt 4. Running this bat prompts to enter the password set when the batch script is set. 5. After the password is passed, the content of the text document a.txt is displayed in the cmd window. Now I don't know how to insert the content of the txt file into a batch script. Please ask me if there is anything unclear in my intention. |
|
| Floor2 HAT | Posted 2010-06-20 00:52 |
| 版主 Posts 5,017 Credits 9,023 | |
|
Where did you see such a batch file?
|
|
| Floor3 Hanyeguxing | Posted 2010-06-20 01:53 |
| 银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂 | |
Originally posted by doshhwa at 2010-6-19 23:39: Drag a.txt to this batch script to start running, and the password must be any permutation of 1234567890ABCDEF. The generated new batch script is the original name plus an underscore such as a_bat. Running the encrypted batch script generates a new text as Hanye.txt For example, the text content is "Cold Night Lone Star", the password is "A197D8E5F6C320B4", and the generated batch script is as follows: @echo off&setlocal enabledelayedexpansion [ Last edited by Hanyeguxing on 2010-6-20 at 02:02 ] |
|
| Floor4 doshhwa | Posted 2010-06-20 13:03 |
| 新手上路 Posts 5 Credits 5 | |
|
I roughly wrote it out.
Now there's a problem: :jm type "%nfile%.bat" | echo @echo off>>"%nfile%.bat" type "%nfile%.bat" | echo title Opening Encrypted Document: "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 Please enter the password. >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo You can see the content of the text document after entering the password. >>"%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= Enter password:>>"%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 Password incorrect!!! Please enter again! >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo You can see the content of the text document after entering the password. >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo set /p mm1= Re-enter password:>>"%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 Please select the way to open the text: >>"%nfile%.bat" type "%nfile%.bat" | echo echo Open in this window.>>"%nfile%.bat" type "%nfile%.bat" | echo echo Generate another new file %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= Select 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 If you want to copy, click right mouse button - Mark>>"%nfile%.bat" type "%nfile%.bat" | echo echo Select the content to be copied - right mouse button >>"%nfile%.bat" type "%nfile%.bat" | echo echo You can complete the copy.>>"%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 File decryption completed!!>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo Please view the newly generated file %nfile%.txt>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo echo Press any key to close...>>"%nfile%.bat" type "%nfile%.bat" | echo pause>nul>>"%nfile%.bat" In the above part, I want to embed %file% into %nfile%.bat Then run %nfile%.bat After entering the pre-set password and selecting the way, %nfile%.bat can generate a new %file% or directly display the content of %file% in the cmd window But I don't know how to do it 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 If you want to copy, click right mouse button - Mark>>"%nfile%.bat" type "%nfile%.bat" | echo echo Select the content to be copied - right mouse button >>"%nfile%.bat" type "%nfile%.bat" | echo echo You can complete the copy.>>"%nfile%.bat" This part of type %file%>>"%nfile%.bat" doesn't seem to work well. [ Last edited by doshhwa on 2010-6-20 at 13:08 ] |
|
| Floor5 doshhwa | Posted 2010-06-20 13:34 |
| 新手上路 Posts 5 Credits 5 | |
|
Now the problem is simplified:
How to put the line if not "%mm%"=="%password%" goto mmcw into %nfile%.bat. If you use type "%nfile%.bat" | echo if not "%mm%"=="%password%" goto mmcw>>"%nfile%.bat", the output will be: if not ""=="asdf" goto mmcw (because password was defined as asdf earlier, so asdf will be displayed) The complete code is: @echo off set /p file= File: set /p nfile= New file: set /p password= Password: :jm type "%nfile%.bat" | echo @echo off>>"%nfile%.bat" type "%nfile%.bat" | echo title Opening encrypted document: "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 Please enter the password. >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo You can see the content of the text document after entering the password. >>"%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= Enter password:>>"%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 Password error!!! Please re-enter! >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo You can see the content of the text document after entering the password. >>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo set /p mm= Re-enter password:>>"%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 Please choose the way to open the text: >>"%nfile%.bat" type "%nfile%.bat" | echo [1] Open in this window.>>"%nfile%.bat" type "%nfile%.bat" | echo [2] Generate another new file %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= Choose the 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 If you want to copy, click right mouse button - Mark>>"%nfile%.bat" type "%nfile%.bat" | echo echo Select the content to be copied - right mouse button >>"%nfile%.bat" type "%nfile%.bat" | echo echo You can complete the copy.>>"%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 File decryption completed!!>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo Please check the newly generated file %nfile%.txt>>"%nfile%.bat" type "%nfile%.bat" | echo echo.>>"%nfile%.bat" type "%nfile%.bat" | echo echo ┗ ┛>>"%nfile%.bat" type "%nfile%.bat" | echo echo Any key to close...>>"%nfile%.bat" type "%nfile%.bat" | echo pause>nul>>"%nfile%.bat" Among them type "%nfile%.bat" | echo if "%way%"=="1" goto zhijiedakai>>"%nfile%.bat" type "%nfile%.bat" | echo if "%way%"=="2" goto newtxt>>"%nfile%.bat" also has the same problem, there is no %way%... in the newly generated file |
|
| Floor6 Hanyeguxing | Posted 2010-06-20 14:32 |
| 银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂 | |
|
I can't see the real encryption and decryption processes in your code.
|
|
| Floor7 doshhwa | Posted 2010-06-20 14:54 |
| 新手上路 Posts 5 Credits 5 | |
|
No, the encryption and decryption segments haven't been added yet.
I don't know how to input the line `if not "%mm%"=="%password%" goto mmcw` into `%nfile%.bat`. If I use `type "%nfile%.bat" | echo if not "%mm%"=="%password%" goto mmcw>>"%nfile%.bat"`, the output will be: if not ""=="asdf" goto mmcw (since password was defined as asdf earlier, so it will display asdf) |
|
| Floor8 acaigg | Posted 2010-12-28 10:32 |
| 初级用户 Posts 92 Credits 115 | |
|
Learning
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |