diff --git a/.gitignore b/.gitignore index 504d63d..c64b468 100644 --- a/.gitignore +++ b/.gitignore @@ -1,37 +1,65 @@ -#Text File -*.txt -*.md -*.log - -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app +#Text file +*.txt +*.md +*.log + +# Source code files +*.c +*.cc +*.cpp +*.cxx +*.h +*.hpp + +# Prerequisites +*.d + +# Compiled object files +*.slo +*.lo +*.o +*.obj +*.objective-binary + +# Precompiled headers +*.gch +*.pch + +# Compiled static libraries +*.a +*.lib + +# Compiled dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled static libraries +*.lai +*.la +*.a +*.lib + +# Executables binary files +*.exe +*.com +*.pkg +*.app +*.AppImage +*.elf + +# Executables text script files +*.cmd +*.bat +*.sh +Makefile +makefile + +#Integrated Development Environment - Code Project Files +*.sln +*.vcxproj +*.cbp diff --git a/About Not Found [Code Block Project File(cbp)].txt b/About Not Found [Code Block Project File(cbp)].txt new file mode 100644 index 0000000..dafbfdf --- /dev/null +++ b/About Not Found [Code Block Project File(cbp)].txt @@ -0,0 +1,11 @@ +Where's the code block project file? (*.cbp) +关于代码块项目文件,它去哪里了? (*.cbp) + +Reply: +---------- + +English +This type of file is temporarily removed. + +Chinese +这个类型的文件,暂时的被移除。 \ No newline at end of file diff --git a/Binary/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/CUI_EncryptDecryptFile_DebugVersion.exe b/Binary/Debug/EODF/Beta-Version/CUI_EncryptDecryptFile_DebugVersion-StaticDatabaseLink.exe similarity index 57% rename from Binary/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/CUI_EncryptDecryptFile_DebugVersion.exe rename to Binary/Debug/EODF/Beta-Version/CUI_EncryptDecryptFile_DebugVersion-StaticDatabaseLink.exe index e069603..f26578f 100644 Binary files a/Binary/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/CUI_EncryptDecryptFile_DebugVersion.exe and b/Binary/Debug/EODF/Beta-Version/CUI_EncryptDecryptFile_DebugVersion-StaticDatabaseLink.exe differ diff --git a/Binary/Debug/EODF/Beta-Version/CUI_EncryptDecryptFile_DebugVersion.exe b/Binary/Debug/EODF/Beta-Version/CUI_EncryptDecryptFile_DebugVersion.exe new file mode 100644 index 0000000..e800755 Binary files /dev/null and b/Binary/Debug/EODF/Beta-Version/CUI_EncryptDecryptFile_DebugVersion.exe differ diff --git a/Binary/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/CUI_EncryptDecryptFile_DebugVersion2.exe b/Binary/Debug/EODF/Beta-Version2/CUI_EncryptDecryptFile_DebugVersion2-StaticDatabaseLink.exe similarity index 56% rename from Binary/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/CUI_EncryptDecryptFile_DebugVersion2.exe rename to Binary/Debug/EODF/Beta-Version2/CUI_EncryptDecryptFile_DebugVersion2-StaticDatabaseLink.exe index df35440..2e0dd17 100644 Binary files a/Binary/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/CUI_EncryptDecryptFile_DebugVersion2.exe and b/Binary/Debug/EODF/Beta-Version2/CUI_EncryptDecryptFile_DebugVersion2-StaticDatabaseLink.exe differ diff --git a/Binary/Debug/EODF/Beta-Version2/CUI_EncryptDecryptFile_DebugVersion2.exe b/Binary/Debug/EODF/Beta-Version2/CUI_EncryptDecryptFile_DebugVersion2.exe new file mode 100644 index 0000000..0c2d378 Binary files /dev/null and b/Binary/Debug/EODF/Beta-Version2/CUI_EncryptDecryptFile_DebugVersion2.exe differ diff --git a/Binary/Debug/EODF/Beta-Version3/CUI_EncryptDecryptFile_DebugVersion3-StaticDatabaseLink.exe b/Binary/Debug/EODF/Beta-Version3/CUI_EncryptDecryptFile_DebugVersion3-StaticDatabaseLink.exe new file mode 100644 index 0000000..feb42bb Binary files /dev/null and b/Binary/Debug/EODF/Beta-Version3/CUI_EncryptDecryptFile_DebugVersion3-StaticDatabaseLink.exe differ diff --git a/Binary/Debug/EODF/Beta-Version3/CUI_EncryptDecryptFile_DebugVersion3.exe b/Binary/Debug/EODF/Beta-Version3/CUI_EncryptDecryptFile_DebugVersion3.exe new file mode 100644 index 0000000..236a21e Binary files /dev/null and b/Binary/Debug/EODF/Beta-Version3/CUI_EncryptDecryptFile_DebugVersion3.exe differ diff --git a/Binary/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/CUI_EncryptDecryptFile_DebugVersion3.exe b/Binary/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/CUI_EncryptDecryptFile_DebugVersion3.exe deleted file mode 100644 index e6799ce..0000000 Binary files a/Binary/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/CUI_EncryptDecryptFile_DebugVersion3.exe and /dev/null differ diff --git a/Binary/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/CUI_EncryptDecryptFile_BetaVersion.exe b/Binary/Release/EODF/Beta-Version/CUI_EncryptDecryptFile_BetaVersion-StaticDatabaseLink.exe similarity index 58% rename from Binary/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/CUI_EncryptDecryptFile_BetaVersion.exe rename to Binary/Release/EODF/Beta-Version/CUI_EncryptDecryptFile_BetaVersion-StaticDatabaseLink.exe index a4bb6f2..f2718ff 100644 Binary files a/Binary/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/CUI_EncryptDecryptFile_BetaVersion.exe and b/Binary/Release/EODF/Beta-Version/CUI_EncryptDecryptFile_BetaVersion-StaticDatabaseLink.exe differ diff --git a/Binary/Release/EODF/Beta-Version/CUI_EncryptDecryptFile_BetaVersion.exe b/Binary/Release/EODF/Beta-Version/CUI_EncryptDecryptFile_BetaVersion.exe new file mode 100644 index 0000000..e8ec6ab Binary files /dev/null and b/Binary/Release/EODF/Beta-Version/CUI_EncryptDecryptFile_BetaVersion.exe differ diff --git a/Binary/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/CUI_EncryptDecryptFile_BetaVersion2.exe b/Binary/Release/EODF/Beta-Version2/CUI_EncryptDecryptFile_BetaVersion2-StaticDatabaseLink.exe similarity index 57% rename from Binary/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/CUI_EncryptDecryptFile_BetaVersion2.exe rename to Binary/Release/EODF/Beta-Version2/CUI_EncryptDecryptFile_BetaVersion2-StaticDatabaseLink.exe index 519d57d..272d02d 100644 Binary files a/Binary/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/CUI_EncryptDecryptFile_BetaVersion2.exe and b/Binary/Release/EODF/Beta-Version2/CUI_EncryptDecryptFile_BetaVersion2-StaticDatabaseLink.exe differ diff --git a/Binary/Release/EODF/Beta-Version2/CUI_EncryptDecryptFile_BetaVersion2.exe b/Binary/Release/EODF/Beta-Version2/CUI_EncryptDecryptFile_BetaVersion2.exe new file mode 100644 index 0000000..5594359 Binary files /dev/null and b/Binary/Release/EODF/Beta-Version2/CUI_EncryptDecryptFile_BetaVersion2.exe differ diff --git a/Binary/Release/EODF/Beta-Version3/CUI_EncryptDecryptFile_BetaVersion3-StaticDatabaseLink.exe b/Binary/Release/EODF/Beta-Version3/CUI_EncryptDecryptFile_BetaVersion3-StaticDatabaseLink.exe new file mode 100644 index 0000000..e266efa Binary files /dev/null and b/Binary/Release/EODF/Beta-Version3/CUI_EncryptDecryptFile_BetaVersion3-StaticDatabaseLink.exe differ diff --git a/Binary/Release/EODF/Beta-Version3/CUI_EncryptDecryptFile_BetaVersion3.exe b/Binary/Release/EODF/Beta-Version3/CUI_EncryptDecryptFile_BetaVersion3.exe new file mode 100644 index 0000000..f508556 Binary files /dev/null and b/Binary/Release/EODF/Beta-Version3/CUI_EncryptDecryptFile_BetaVersion3.exe differ diff --git a/Binary/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/CUI_EncryptDecryptFile_BetaVersion3.exe b/Binary/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/CUI_EncryptDecryptFile_BetaVersion3.exe deleted file mode 100644 index 8044dc5..0000000 Binary files a/Binary/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/CUI_EncryptDecryptFile_BetaVersion3.exe and /dev/null differ diff --git a/Custom-Makefile-Twlilght_Yujiang/Makefile b/Custom-Makefile-Twlilght_Yujiang/Makefile deleted file mode 100644 index 13a3c1a..0000000 --- a/Custom-Makefile-Twlilght_Yujiang/Makefile +++ /dev/null @@ -1,166 +0,0 @@ -#This File Makefile Scrpit - -#Comand Separator Tab Keyboard!!! - -include Makefile.Header - -.PHONY = all beta_version beta_version2 beta_version3 bebug_mode_version bebug_mode_version2 bebug_mode_version3 run.bat run_bebug.bat run run_bebug clean LINK_OBJECTIVE LINK_OBJECTIVES -all: - - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 01 - - - @make debug_mode_version - - @make debug_mode_version2 - - @make debug_mode_version3 - - - @make beta_version - - @make beta_version2 - - @make beta_version3 - -beta_version: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 02 - - - $(CREATE_FOLDER) $(RELEASE_OBJECTIVES_VERSION_FOLDER) - - $(CREATE_FOLDER) $(RELEASE_EXECUTE_VERSION_FOLDER) - - $(MINGW_CPP) -Wall -O2 -c $(SOURCES_VERSION) -o $(RELEASE_OBJECTIVES_VERSION) - - $(LINK_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION) -o $(RELEASE_EXECUTE_FILE_VERSION) - -beta_version2: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 03 - - - $(CREATE_FOLDER) $(RELEASE_OBJECTIVES_VERSION2_FOLDER) - - $(CREATE_FOLDER) $(RELEASE_EXECUTE_VERSION2_FOLDER) - - $(MINGW_CPP) -Wall -O2 -c $(SOURCES_VERSION2) -o $(RELEASE_OBJECTIVES_VERSION2) - - $(LINK_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION2) -o $(RELEASE_EXECUTE_FILE_VERSION2) - -beta_version3: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 04 - - - $(CREATE_FOLDER) $(RELEASE_OBJECTIVES_VERSION3_FOLDER) - - $(CREATE_FOLDER) $(RELEASE_EXECUTE_VERSION3_FOLDER) - - $(MINGW_CPP) -Wall -O2 -c $(SOURCES_VERSION3) -o $(RELEASE_OBJECTIVES_VERSION3) - - $(LINK_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION3) -o $(RELEASE_EXECUTE_FILE_VERSION3) - -debug_mode_version: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 05 - - - $(CREATE_FOLDER) $(DEBUG_OBJECTIVES_VERSION_FOLDER) - - $(CREATE_FOLDER) $(DEBUG_EXECUTE_VERSION_FOLDER) - - $(MINGW_DEBUG_CPP) $(SOURCES_VERSION) -o $(DEBUG_OBJECTIVES_VERSION) - - $(LINK_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION) -o $(DEBUG_EXECUTE_FILE_VERSION) - -debug_mode_version2: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 06 - - - $(CREATE_FOLDER) $(DEBUG_OBJECTIVES_VERSION2_FOLDER) - - $(CREATE_FOLDER) $(DEBUG_EXECUTE_VERSION2_FOLDER) - - $(MINGW_DEBUG_CPP) $(SOURCES_VERSION2) -o $(DEBUG_OBJECTIVES_VERSION2) - - $(LINK_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION2) -o $(DEBUG_EXECUTE_FILE_VERSION2) - -debug_mode_version3: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 07 - - - $(CREATE_FOLDER) $(DEBUG_OBJECTIVES_VERSION3_FOLDER) - - $(CREATE_FOLDER) $(DEBUG_EXECUTE_VERSION3_FOLDER) - - $(MINGW_DEBUG_CPP) $(SOURCES_VERSION3) -o $(DEBUG_OBJECTIVES_VERSION3) - - $(LINK_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION3) -o $(DEBUG_EXECUTE_FILE_VERSION3) - -run.bat: - - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 08 - - @echo @echo off >> run.bat - - @echo.>>run.bat - - @echo cd /d $(RELEASE_EXECUTE_VERSION3_FOLDER) >> run.bat - - @echo.>>run.bat - - @echo start CUI_EncryptDecryptFile_BetaVersion3.exe >> run.bat - - start ".\\run.bat" - -run_debug.bat: - - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 09 - - cd /d ".\\" - - @echo @echo off >> run_debug.bat - - @echo.>>run_debug.bat - - @echo cd /d $(DEBUG_EXECUTE_VERSION3_FOLDER) >> run.bat - - @echo.>>run_debug.bat - - @echo start CUI_EncryptDecryptFile_DebugVersion3.exe >> run_debug.bat - - start ".\\run_debug.bat" - -run: - - - make run.bat - -run_debug: - - - make run_debug.bat - -clean: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 10 - - - $(DELETE) $(DEBUG_OBJECTIVES_VERSION) - - $(DELETE) $(DEBUG_OBJECTIVES_VERSION2) - - $(DELETE) $(DEBUG_OBJECTIVES_VERSION3) - - - $(DELETE) $(DEBUG_EXECUTE_FILE_VERSION) - - $(DELETE) $(DEBUG_EXECUTE_FILE_VERSION2) - - $(DELETE) $(DEBUG_EXECUTE_FILE_VERSION3) - - - $(DELETE) $(RELEASE_OBJECTIVES_VERSION) - - $(DELETE) $(RELEASE_OBJECTIVES_VERSION2) - - $(DELETE) $(RELEASE_OBJECTIVES_VERSION3) - - - $(DELETE) $(RELEASE_EXECUTE_FILE_VERSION) - - $(DELETE) $(RELEASE_EXECUTE_FILE_VERSION2) - - $(DELETE) $(RELEASE_EXECUTE_FILE_VERSION3) - - - $(DELETE) ".\\Binary\\Debug\\*.exe" - - $(DELETE) ".\\Binary\\Release\\*.exe" - - $(DELETE) ".\\Objectives\\Debug\\*.o" - - $(DELETE) ".\\Objectives\\Release\\*.o" - - - $(DELETE) ".\\run.bat" - - - $(REMOVE_FOLDER) $(DEBUG_OBJECTIVES_VERSION_FOLDER) - - $(REMOVE_FOLDER) $(DEBUG_OBJECTIVES_VERSION2_FOLDER) - - $(REMOVE_FOLDER) $(DEBUG_OBJECTIVES_VERSION3_FOLDER) - - - $(REMOVE_FOLDER) $(RELEASE_OBJECTIVES_VERSION_FOLDER) - - $(REMOVE_FOLDER) $(RELEASE_OBJECTIVES_VERSION2_FOLDER) - - $(REMOVE_FOLDER) $(RELEASE_OBJECTIVES_VERSION3_FOLDER) - - - $(REMOVE_FOLDER) $(DEBUG_EXECUTE_VERSION_FOLDER) - - $(REMOVE_FOLDER) $(DEBUG_EXECUTE_VERSION2_FOLDER) - - $(REMOVE_FOLDER) $(DEBUG_EXECUTE_VERSION3_FOLDER) - - - $(REMOVE_FOLDER) $(RELEASE_EXECUTE_VERSION_FOLDER) - - $(REMOVE_FOLDER) $(RELEASE_EXECUTE_VERSION2_FOLDER) - - $(REMOVE_FOLDER) $(RELEASE_EXECUTE_VERSION3_FOLDER) - - - $(REMOVE_FOLDER) ".\\Binary\\" - - $(REMOVE_FOLDER) ".\\Objectives\\" - - - $(DELETE) ".\\run_debug.bat" diff --git a/Custom-Makefile-Twlilght_Yujiang/Makefile.Header b/Custom-Makefile-Twlilght_Yujiang/Makefile.Header deleted file mode 100644 index 5b13e25..0000000 --- a/Custom-Makefile-Twlilght_Yujiang/Makefile.Header +++ /dev/null @@ -1,52 +0,0 @@ -#This File Makefile Scrpit Header - -#Workspace File - -HIDDEN_RUN_MODE=@echo off -COMMAND_WINDOW_COLOR=@color - -DELETE=@del /s /f /q -CREATE_FOLDER=@mkdir -REMOVE_FOLDER=@rmdir /s /q - -MINGW_CPP=@g++ -Wall -O2 -c -MINGW_DEBUG_CPP=@g++ -Wall -fexceptions -g -c -LINK_OBJECTIVES=g++ -static - -SOURCES_VERSION=".\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\Main_By_Twlilght_Yujiang.cpp" -SOURCES_VERSION2=".\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\Main_2_By_Twlilght_Yujiang.cpp" -SOURCES_VERSION3=".\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\Main_3_By_Twlilght_Yujiang.cpp" - -DEBUG_OBJECTIVES_VERSION=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\Main_By_Twlilght_Yujiang.o" -DEBUG_OBJECTIVES_VERSION2=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\Main_2_By_Twlilght_Yujiang.o" -DEBUG_OBJECTIVES_VERSION3=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\Main_3_By_Twlilght_Yujiang.o" - -DEBUG_EXECUTE_FILE_VERSION=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\CUI_EncryptDecryptFile_DebugVersion.exe" -DEBUG_EXECUTE_FILE_VERSION2=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\CUI_EncryptDecryptFile_DebugVersion2.exe" -DEBUG_EXECUTE_FILE_VERSION3=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\CUI_EncryptDecryptFile_DebugVersion3.exe" - -RELEASE_OBJECTIVES_VERSION=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\Main_By_Twlilght_Yujiang.o" -RELEASE_OBJECTIVES_VERSION2=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\Main_2_By_Twlilght_Yujiang.o" -RELEASE_OBJECTIVES_VERSION3=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\Main_3_By_Twlilght_Yujiang.o" - -RELEASE_EXECUTE_FILE_VERSION=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\CUI_EncryptDecryptFile_BetaVersion.exe" -RELEASE_EXECUTE_FILE_VERSION2=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\CUI_EncryptDecryptFile_BetaVersion2.exe" -RELEASE_EXECUTE_FILE_VERSION3=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\CUI_EncryptDecryptFile_BetaVersion3.exe" - -#Make Workspace Folder - -DEBUG_OBJECTIVES_VERSION_FOLDER=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\" -DEBUG_OBJECTIVES_VERSION2_FOLDER=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\" -DEBUG_OBJECTIVES_VERSION3_FOLDER=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\" - -RELEASE_OBJECTIVES_VERSION_FOLDER=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\" -RELEASE_OBJECTIVES_VERSION2_FOLDER=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\" -RELEASE_OBJECTIVES_VERSION3_FOLDER=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\" - -DEBUG_EXECUTE_VERSION_FOLDER=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\" -DEBUG_EXECUTE_VERSION2_FOLDER=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\" -DEBUG_EXECUTE_VERSION3_FOLDER=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\" - -RELEASE_EXECUTE_VERSION_FOLDER=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\" -RELEASE_EXECUTE_VERSION2_FOLDER=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\" -RELEASE_EXECUTE_VERSION3_FOLDER=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\" \ No newline at end of file diff --git "a/Custom-Makefile/About This Directory(\345\205\263\344\272\216\350\277\231\344\270\252\347\233\256\345\275\225).md" "b/Custom-Makefile/About This Directory(\345\205\263\344\272\216\350\277\231\344\270\252\347\233\256\345\275\225).md" new file mode 100644 index 0000000..4bcaffa --- /dev/null +++ "b/Custom-Makefile/About This Directory(\345\205\263\344\272\216\350\277\231\344\270\252\347\233\256\345\275\225).md" @@ -0,0 +1,7 @@ +#Information 淇℃伅 + +##This is the root directory where the (MAKEFILE) executes the compilation in this Code project. +##Request you, absolutely do not delete it! +----- +##杩欐槸涓涓紝鍦ㄨ繖涓唬鐮佸伐绋嬮噷闈㈢殑锛(MAKEFILE)鎵ц缂栬瘧鐨勬牴鐩綍銆 +##璇锋眰浣狅紝缁濆涓嶈鍒犻櫎瀹! \ No newline at end of file diff --git a/Custom-Makefile/Makefile b/Custom-Makefile/Makefile new file mode 100644 index 0000000..94de7eb --- /dev/null +++ b/Custom-Makefile/Makefile @@ -0,0 +1,299 @@ +#This File Makefile Script + +#Comand Separator Tab Keyboard!!! + +include Makefile.Header + +.PHONY = all clean +.PHONY = build_version1 build_version2 build_version3 +.PHONY = bebug_mode_version bebug_mode_version2 bebug_mode_version3 +.PHONY = beta_version beta_version2 beta_version3 +.PHONY = run run_bebug run.bat run_bebug.bat +.PHONY = LINKING_OBJECTIVES STATIC_LINKING_OBJECTIVES + + + +#Build All Project File + + + +all: + + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 01 + + - @make debug_mode_version + - @pause + - @make debug_mode_version2 + - @pause + - @make debug_mode_version3 + - @pause + - @cls + + - @make beta_version + - @pause + - @make beta_version2 + - @pause + - @make beta_version3 + - @pause + - @cls + - $(COMMAND_WINDOW_COLOR) 01 + + + +#Build One Version Project File + + + +build_version1: + + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 12 + - @make debug_mode_version + - @make beta_version + - @pause + - @cls + +build_version2: + + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 12 + - @make debug_mode_version2 + - @make beta_version2 + - @pause + - @cls + +build_version3: + + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 12 + - @make debug_mode_version3 + - @make beta_version3 + - @pause + - @cls + + + +#Build Debug File + + + +debug_mode_version: + + - @cd /d %~dp0 + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 05 + + - $(CREATE_FOLDER) $(DEBUG_OBJECTIVES_VERSION_FOLDER) + - $(CREATE_FOLDER) $(DEBUG_EXECUTE_VERSION_FOLDER) + - $(MINGW_DEBUG_CPP) $(SOURCES_VERSION) -o $(DEBUG_OBJECTIVES_VERSION) + - @pause + - @cls + - $(LINKING_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION) -o $(DEBUG_EXECUTE_FILE_VERSION) + - $(STATIC_LINKING_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION) -o $(DEBUG_STATIC_EXECUTE_FILE_VERSION) + - @pause + - @cls + +debug_mode_version2: + + - @cd /d %~dp0 + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 06 + + - $(CREATE_FOLDER) $(DEBUG_OBJECTIVES_VERSION2_FOLDER) + - $(CREATE_FOLDER) $(DEBUG_EXECUTE_VERSION2_FOLDER) + - $(MINGW_DEBUG_CPP) $(SOURCES_VERSION2) -o $(DEBUG_OBJECTIVES_VERSION2) + - @pause + - @cls + - $(LINKING_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION2) -o $(DEBUG_EXECUTE_FILE_VERSION2) + - $(STATIC_LINKING_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION2) -o $(DEBUG_STATIC_EXECUTE_FILE_VERSION2) + - @pause + - @cls + +debug_mode_version3: + + - @cd /d %~dp0 + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 07 + + - $(CREATE_FOLDER) $(DEBUG_OBJECTIVES_VERSION3_FOLDER) + - $(CREATE_FOLDER) $(DEBUG_EXECUTE_VERSION3_FOLDER) + - $(MINGW_DEBUG_CPP) $(SOURCES_VERSION3) -o $(DEBUG_OBJECTIVES_VERSION3) + - @pause + - @cls + - $(LINKING_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION3) -o $(DEBUG_EXECUTE_FILE_VERSION3) + - $(STATIC_LINKING_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION3) -o $(DEBUG_STATIC_EXECUTE_FILE_VERSION3) + - @pause + - @cls + + + +#Build Beta File + + + +beta_version: + + - @cd /d %~dp0 + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 02 + + - $(CREATE_FOLDER) $(RELEASE_OBJECTIVES_VERSION_FOLDER) + - $(CREATE_FOLDER) $(RELEASE_EXECUTE_VERSION_FOLDER) + - $(MINGW_CPP) -Wall -O2 -c $(SOURCES_VERSION) -o $(RELEASE_OBJECTIVES_VERSION) + - @pause + - @cls + - $(LINKING_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION) -o $(RELEASE_EXECUTE_FILE_VERSION) + - $(STATIC_LINKING_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION) -o $(RELEASE_STATIC_EXECUTE_FILE_VERSION) + - @pause + - @cls + +beta_version2: + + - @cd /d %~dp0 + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 03 + + - $(CREATE_FOLDER) $(RELEASE_OBJECTIVES_VERSION2_FOLDER) + - $(CREATE_FOLDER) $(RELEASE_EXECUTE_VERSION2_FOLDER) + - $(MINGW_CPP) -Wall -O2 -c $(SOURCES_VERSION2) -o $(RELEASE_OBJECTIVES_VERSION2) + - @pause + - @cls + - $(LINKING_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION2) -o $(RELEASE_EXECUTE_FILE_VERSION2) + - $(STATIC_LINKING_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION2) -o $(RELEASE_STATIC_EXECUTE_FILE_VERSION2) + +beta_version3: + + - @cd /d %~dp0 + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 04 + + - $(CREATE_FOLDER) $(RELEASE_OBJECTIVES_VERSION3_FOLDER) + - $(CREATE_FOLDER) $(RELEASE_EXECUTE_VERSION3_FOLDER) + - $(MINGW_CPP) -Wall -O2 -c $(SOURCES_VERSION3) -o $(RELEASE_OBJECTIVES_VERSION3) + - @pause + - @cls + - $(LINKING_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION3) -o $(RELEASE_EXECUTE_FILE_VERSION3) + - $(STATIC_LINKING_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION3) -o $(RELEASE_STATIC_EXECUTE_FILE_VERSION3) + - @pause + - @cls + + + +#Run Program + + + +run.bat: + + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 08 + - cd /d %~dp0 + - @echo @echo off >> run.bat + - @echo.>>run.bat + - @echo cd /d $(RELEASE_EXECUTE_VERSION3_FOLDER) >> run.bat + - @echo.>>run.bat + - @echo start .\\CUI_EncryptDecryptFile_BetaVersion3.exe >> run.bat + - start ".\\run.bat" + +run_debug.bat: + + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 09 + - cd /d %~dp0 + - @echo @echo off >> run_debug.bat + - @echo.>>run_debug.bat + - @echo cd /d $(DEBUG_EXECUTE_VERSION3_FOLDER) >> run_debug.bat + - @echo.>>run_debug.bat + - @echo start .\\CUI_EncryptDecryptFile_DebugVersion3.exe >> run_debug.bat + - start ".\\run_debug.bat" + +run: + + - make run.bat + +run_debug: + + - make run_debug.bat + + + +#Clean This Project + + + +clean: + + - @cd /d %~dp0 + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 10 + + - $(DELETE) $(DEBUG_OBJECTIVES_VERSION) + - $(DELETE) $(DEBUG_OBJECTIVES_VERSION2) + - $(DELETE) $(DEBUG_OBJECTIVES_VERSION3) + + - $(DELETE) $(DEBUG_EXECUTE_FILE_VERSION) + - $(DELETE) $(DEBUG_EXECUTE_FILE_VERSION2) + - $(DELETE) $(DEBUG_EXECUTE_FILE_VERSION3) + + - $(DELETE) $(RELEASE_OBJECTIVES_VERSION) + - $(DELETE) $(RELEASE_OBJECTIVES_VERSION2) + - $(DELETE) $(RELEASE_OBJECTIVES_VERSION3) + + - $(DELETE) $(RELEASE_EXECUTE_FILE_VERSION) + - $(DELETE) $(RELEASE_EXECUTE_FILE_VERSION2) + - $(DELETE) $(RELEASE_EXECUTE_FILE_VERSION3) + + - $(DELETE) "..\\Binary\\Debug\\*.exe" + - $(DELETE) "..\\Binary\\Release\\*.exe" + - $(DELETE) "..\\Objectives\\Debug\\*.o" + - $(DELETE) "..\\Objectives\\Release\\*.o" + + - $(DELETE) "..\\run.bat" + + - $(REMOVE_FOLDER) $(DEBUG_OBJECTIVES_VERSION_FOLDER) + - $(REMOVE_FOLDER) $(DEBUG_OBJECTIVES_VERSION2_FOLDER) + - $(REMOVE_FOLDER) $(DEBUG_OBJECTIVES_VERSION3_FOLDER) + + - $(REMOVE_FOLDER) $(RELEASE_OBJECTIVES_VERSION_FOLDER) + - $(REMOVE_FOLDER) $(RELEASE_OBJECTIVES_VERSION2_FOLDER) + - $(REMOVE_FOLDER) $(RELEASE_OBJECTIVES_VERSION3_FOLDER) + + - $(REMOVE_FOLDER) $(DEBUG_EXECUTE_VERSION_FOLDER) + - $(REMOVE_FOLDER) $(DEBUG_EXECUTE_VERSION2_FOLDER) + - $(REMOVE_FOLDER) $(DEBUG_EXECUTE_VERSION3_FOLDER) + + - $(REMOVE_FOLDER) $(RELEASE_EXECUTE_VERSION_FOLDER) + - $(REMOVE_FOLDER) $(RELEASE_EXECUTE_VERSION2_FOLDER) + - $(REMOVE_FOLDER) $(RELEASE_EXECUTE_VERSION3_FOLDER) + + - $(REMOVE_FOLDER) "..\\Binary\\" + - $(REMOVE_FOLDER) "..\\Objectives\\" + + - $(DELETE) "..\\run_debug.bat" + + + +#Display Help Massage + + + +help: + + - $(HIDDEN_RUN_MODE) + - $(COMMAND_WINDOW_COLOR) 11 + - @cls + - @echo "make all" + - @echo "make build_version1" + - @echo "make build_version2" + - @echo "make build_version3" + - @echo "make debug_mode_version (debug)" + - @echo "make debug_mode_version2 (debug)" + - @echo "make debug_mode_version3 (debug)" + - @echo "make beta_version (release)" + - @echo "make beta_version2 (release)" + - @echo "make beta_version3 (release)" + - @echo "make run" + - @echo "make run_debug" + - @echo "make clean" + - @echo "make help" diff --git a/Custom-Makefile/Makefile.Header b/Custom-Makefile/Makefile.Header new file mode 100644 index 0000000..428a9d4 --- /dev/null +++ b/Custom-Makefile/Makefile.Header @@ -0,0 +1,71 @@ +#This File Makefile Script Header + +#Workspace File + +HIDDEN_RUN_MODE=@echo off +COMMAND_WINDOW_COLOR=@color + +DELETE=@del /s /f /q +CREATE_FOLDER=@mkdir +REMOVE_FOLDER=@rmdir /s /q + +#gcc.exe -s -o +#gcc.exe -finput-charset=UTF-8 -fexec-charset=GB2312 + +MINGW_CPP=@g++ -fexec-charset=UTF-8 -O2 -c +MINGW_DEBUG_CPP=@g++ -fexec-charset=UTF-8 -fexceptions -g -c +MINGW_WARNING=@g++ -Wall +LINKING_OBJECTIVES=g++ -shared +STATIC_LINKING_OBJECTIVES=g++ -static + +#Source Code File + +SOURCES_VERSION="..\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\Main_EODF_By_TDOM.cpp" +SOURCES_VERSION2="..\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\Main_EODF2_By_TDOM.cpp" +SOURCES_VERSION3="..\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\Main_EODF3_By_TDOM.cpp" + +#Debug Configure + +DEBUG_OBJECTIVES_VERSION="..\\Objectives\\Debug\\EODF\\Beta-Version\\Main_EODF_By_TDOM.o" +DEBUG_OBJECTIVES_VERSION2="..\\Objectives\\Debug\\EODF\\Beta-Version2\\Main_EODF2_By_TDOM.o" +DEBUG_OBJECTIVES_VERSION3="..\\Objectives\\Debug\\EODF\\Beta-Version3\\Main_EODF3_By_TDOM.o" + +DEBUG_EXECUTE_FILE_VERSION="..\\Binary\\Debug\\EODF\\Beta-Version\\CUI_EncryptDecryptFile_DebugVersion.exe" +DEBUG_EXECUTE_FILE_VERSION2="..\\Binary\\Debug\\EODF\\Beta-Version2\\CUI_EncryptDecryptFile_DebugVersion2.exe" +DEBUG_EXECUTE_FILE_VERSION3="..\\Binary\\Debug\\EODF\\Beta-Version3\\CUI_EncryptDecryptFile_DebugVersion3.exe" + +DEBUG_STATIC_EXECUTE_FILE_VERSION="..\\Binary\\Debug\\EODF\\Beta-Version\\CUI_EncryptDecryptFile_DebugVersion-StaticDatabaseLink.exe" +DEBUG_STATIC_EXECUTE_FILE_VERSION2="..\\Binary\\Debug\\EODF\\Beta-Version2\\CUI_EncryptDecryptFile_DebugVersion2-StaticDatabaseLink.exe" +DEBUG_STATIC_EXECUTE_FILE_VERSION3="..\\Binary\\Debug\\EODF\\Beta-Version3\\CUI_EncryptDecryptFile_DebugVersion3-StaticDatabaseLink.exe" + +#Release Configure + +RELEASE_OBJECTIVES_VERSION="..\\Objectives\\Release\\EODF\\Beta-Version\\Main_EODF_By_TDOM.o" +RELEASE_OBJECTIVES_VERSION2="..\\Objectives\\Release\\EODF\\Beta-Version2\\Main_EODF2_By_TDOM.o" +RELEASE_OBJECTIVES_VERSION3="..\\Objectives\\Release\\EODF\\Beta-Version3\\Main_EODF3_By_TDOM.o" + +RELEASE_EXECUTE_FILE_VERSION="..\\Binary\\Release\\EODF\\Beta-Version\\CUI_EncryptDecryptFile_BetaVersion.exe" +RELEASE_EXECUTE_FILE_VERSION2="..\\Binary\\Release\\EODF\\Beta-Version2\\CUI_EncryptDecryptFile_BetaVersion2.exe" +RELEASE_EXECUTE_FILE_VERSION3="..\\Binary\\Release\\EODF\\Beta-Version3\\CUI_EncryptDecryptFile_BetaVersion3.exe" + +RELEASE_STATIC_EXECUTE_FILE_VERSION="..\\Binary\\Release\\EODF\\Beta-Version\\CUI_EncryptDecryptFile_BetaVersion-StaticDatabaseLink.exe" +RELEASE_STATIC_EXECUTE_FILE_VERSION2="..\\Binary\\Release\\EODF\\Beta-Version2\\CUI_EncryptDecryptFile_BetaVersion2-StaticDatabaseLink.exe" +RELEASE_STATIC_EXECUTE_FILE_VERSION3="..\\Binary\\Release\\EODF\\Beta-Version3\\CUI_EncryptDecryptFile_BetaVersion3-StaticDatabaseLink.exe" + +#Make Workspace Folder + +DEBUG_OBJECTIVES_VERSION_FOLDER="..\\Objectives\\Debug\\EODF\\Beta-Version\\" +DEBUG_OBJECTIVES_VERSION2_FOLDER="..\\Objectives\\Debug\\EODF\\Beta-Version2\\" +DEBUG_OBJECTIVES_VERSION3_FOLDER="..\\Objectives\\Debug\\EODF\\Beta-Version3\\" + +DEBUG_EXECUTE_VERSION_FOLDER="..\\Binary\\Debug\\EODF\\Beta-Version\\" +DEBUG_EXECUTE_VERSION2_FOLDER="..\\Binary\\Debug\\EODF\\Beta-Version2\\" +DEBUG_EXECUTE_VERSION3_FOLDER="..\\Binary\\Debug\\EODF\\Beta-Version3\\" + +RELEASE_OBJECTIVES_VERSION_FOLDER="..\\Objectives\\Release\\EODF\\Beta-Version\\" +RELEASE_OBJECTIVES_VERSION2_FOLDER="..\\Objectives\\Release\\EODF\\Beta-Version2\\" +RELEASE_OBJECTIVES_VERSION3_FOLDER="..\\Objectives\\Release\\EODF\\Beta-Version3\\" + +RELEASE_EXECUTE_VERSION_FOLDER="..\\Binary\\Release\\EODF\\Beta-Version\\" +RELEASE_EXECUTE_VERSION2_FOLDER="..\\Binary\\Release\\EODF\\Beta-Version2\\" +RELEASE_EXECUTE_VERSION3_FOLDER="..\\Binary\\Release\\EODF\\Beta-Version3\\" diff --git a/Custom-Makefile/Microsoft-Windows_This-Project-Makefile.zip b/Custom-Makefile/Microsoft-Windows_This-Project-Makefile.zip new file mode 100644 index 0000000..e9fdac1 Binary files /dev/null and b/Custom-Makefile/Microsoft-Windows_This-Project-Makefile.zip differ diff --git a/ErrorDebug_Source_Code/[Error]Main_DebuggingVersion.cpp b/ErrorDebug_Source_Code/[Error]Main_DebuggingVersion.cpp deleted file mode 100644 index 42acb47..0000000 --- a/ErrorDebug_Source_Code/[Error]Main_DebuggingVersion.cpp +++ /dev/null @@ -1,883 +0,0 @@ -/**************************************************************************** -Read Me - About This Source Code File - -Chinese中文: -计算机语言类型: C++ -程序文件名: Twlilght_Yujiang_File_Lock -程序平台类型: Windows 命令行控制台 -程序实际作用: 文件对称式加密解密 -版本: Debugging 1.0 -源代码修改时间: 2017-8-11 -作者:Twlilght_Yujiang - -English英文: -Chinese -Computer Language Type: C++ -Program File Name: Twlilght_Yujiang_File_Lock -Program Platform Type: Windows Command Line Console -The actual role of the program: file symmetric encryption and decryption -Version: Debugging 1.0 -Source code modified by: 2017-8-11 -Author: Twlilght_Yujiang -*****************************************************************************/ - -#include -#include -#include //C标准输入输出函数 -#include //C标准库函数 -#include //字符串处理函数 -#include - -using namespace std; - -//typedef unsigned char byte; - -int RunEncryptFile(char *E_SFN, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_TFN); -int RunDecryptFile(char *D_STN, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_TFN); - -void DOSColorSet(int R,int G,int B) -{ - if(R<0) R=0; - if(R>1) R=1; - - if(G<0) G=0; - if(G>1) G=1; - - if(B<0) B=0; - if(B>1) B=1; - - if(R == 1 && G == 1 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE); - } - else if(R == 1 && G == 1 && B == 0) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN); - } - else if(R == 1 && G == 0 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE); - } - else if(R == 0 && G == 1 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE); - } - else if(R == 1 && G == 0 && B == 0) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED); - } - else if(R == 0 && G == 1 && B == 0) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN); - } - else if(R == 0 && G == 0 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE); - } - else - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY); - } -} - -int main() -{ -ProgramMainMenu: - - string Load_User_Keyboard_Input; - - system("color 0A"); - - std :: cout << "----------" << endl; - std :: cout << "Enter 1 EncryptFile" << endl; - std :: cout << "Enter 2 DecryptFile" << endl; - std :: cout << "Enter 3 Exit Program" << endl; - std :: cout << "----------" << endl; - std :: cout << "" << endl; - std :: cout << "System:Input And Output/Enter>"; - - std :: cin >> Load_User_Keyboard_Input; - getchar(); - - if(Load_User_Keyboard_Input == "1") - { - system("cls"); - system("color 1A"); - - string E_SourceFileName, // 加密的文件名 - E_TargetFileNewName; // 加密后要保存的文件名 - - char* E_SFN; - char* E_TFN; - - //char E_TargetFileLastNameOutput = (E_TargetFileNewName + ".TY_ENCRYPTED"); //最后保存的加密后文件名 - - char E_KEY[128], //File (Encryption or Encrypted) key 文件加密密钥 - E_KEY2[128], - E_KEY3[128]; - - std :: cout << "Please input >>> the source file name.\n(Contains the directory name):" << endl; - std :: cout << "输入要加密的文件名,[C:\](含路径):" << endl; - std :: cin >> E_SourceFileName; - int String_Length = E_SourceFileName.length(); - E_SFN = (char *)malloc((String_Length+1)*sizeof(char)); - E_SourceFileName.copy(E_SFN,String_Length,0); - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥,不要输入空格:" << endl; //密钥是用户自己定义的,(长度小于128)。可以随意给需要加密的文件添加密钥 - std :: cout << "Please input >>> the key,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> E_KEY; - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥2,不要输入空格:" << endl; //密钥是用户自己定义的,(长度小于128)。可以随意给需要加密的文件添加密钥 - std :: cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> E_KEY2; - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥3,不要输入空格:" << endl; //密钥是用户自己定义的,(长度小于128)。可以随意给需要加密的文件添加密钥 - std :: cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> E_KEY3; - - std :: cout << "\n"; - std :: cout << "Please input >>> the target file new name(Contains the directory name):" << endl; - std :: cout << "加密后的文件名(含路径):" << endl; //给加密后的文件命名,并保存 - std :: cin >> E_TargetFileNewName; - int String_Length2 = E_TargetFileNewName.length(); - E_TFN = (char *)malloc((String_Length2+1)*sizeof(char)); - E_TargetFileNewName.copy(E_TFN,String_Length2,0); - - system("cls"); - - std :: cout << "正在记录并导出,本次用于文件加密,3个密钥字符串......" << endl; - std :: cout << "Is being recorded and exported, this time for file encryption, 3 key string......" << endl; - ofstream PasswordOutputKeyFile; - PasswordOutputKeyFile.open("FILE-ENCRYPTION-DECRYPTIPN-PASSWORD.KEY.TXT"); - PasswordOutputKeyFile << "Twlilght_Yujiang File Lock Password [Key String] Save\n" << endl; - PasswordOutputKeyFile << "\n" << endl; - PasswordOutputKeyFile << "Source Input File Name and Path: " << E_SourceFileName << "\n" << endl; - PasswordOutputKeyFile << "EncryptFile: New Output Target File Name and Path: " << E_TargetFileNewName << "\n" << endl; - PasswordOutputKeyFile << "Key string1 [Password1]: " << E_KEY << "\n" << endl; - PasswordOutputKeyFile << "Key string2 [Password2]: " << E_KEY2 << "\n" << endl; - PasswordOutputKeyFile << "Key string3 [Password3]: " << E_KEY3 << "\n" << endl; - PasswordOutputKeyFile << "<******************************************************************************************>" << "\n" << endl; - PasswordOutputKeyFile.close(); - - - - std :: cout << "Please wait, read and write in the file......" << endl; - std :: cout << "请等待,文件读写中......" << endl; - getchar(); - - if(RunEncryptFile(E_SFN, E_KEY, E_KEY2, E_KEY3, E_TFN)) - { - printf("恭喜你,文件[%s]加密成功,保存在[%s]。\n", E_SFN, E_TFN); - printf("Congratulations, the file [%s] is encrypted successfully, saved in [%s]. \n", E_SFN, E_TFN); - getchar(); - system("pause"); - system("cls"); - goto ProgramMainMenu; - } - } - if(Load_User_Keyboard_Input == "2") - { - system("cls"); - system("color 1A"); - - string D_SourceFileName, //源文件名 - D_TargetFileNewName; //目标文件新名称 - - char* D_SFN; - char* D_TFN; - - //char D_TargetFileLastNameOutput = (D_TargetFileNewName - ".TY_ENCRYPTED"); //最后保存的解密后文件名 - - char D_KEY[128], //File (Decryption or Decrypted) key 文件解密密钥 - D_KEY2[128], - D_KEY3[128]; - - std :: cout << "\n"; - std :: cout << "Please input >>> the source file name.\nDo not enter spaces!\n(Contains the directory name):" << endl; - std :: cout << "输入要解密的文件名,[C:\]不要输入空格(含路径):" << endl; - std :: cin >> D_SourceFileName; - int String_Length3 = D_SourceFileName.length(); - D_SFN = (char *)malloc((String_Length3+1)*sizeof(char)); - D_SourceFileName.copy(D_SFN,String_Length3,0); - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥,不要输入空格:" << endl; //密钥是用户自己定义的,可以随意给需要解密的文件输入密钥 - std :: cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> D_KEY; - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥2,不要输入空格:" << endl; - std :: cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> D_KEY2; - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥3,不要输入空格:" << endl; - std :: cout << "Please input >>> the key,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> D_KEY3; - - std :: cout << "\n"; - std :: cout << "Please input >>> the target file new name(Contains the directory name):" << endl; - std :: cout << "解密后的文件名,不要输入空格(含路径):" << endl; //给解密后的文件命名,并保存 - std :: cin >> D_TargetFileNewName; - int String_Length4 = D_TargetFileNewName.length(); - D_TFN = (char *)malloc((String_Length4+1)*sizeof(char)); - D_TargetFileNewName.copy(D_TFN,String_Length4,0); - - system("cls"); - - std :: cout << "Please wait, read and write in the file......" << endl; - std :: cout << "请等待,文件读写中......" << endl; - getchar(); - - if(RunDecryptFile(D_SFN, D_KEY, D_KEY2, D_KEY3, D_TFN)) - { - printf("恭喜你,文件[%s]解密成功,保存在[%s]。\n", D_SFN, D_TFN); - printf("Congratulations, the file [%s] is decrypted successfully, saved in [%s]. \n", D_SFN, D_TFN); - getchar(); - system("pause"); - system("cls"); - goto ProgramMainMenu; - } - } - - if(Load_User_Keyboard_Input == "3") - { - return 0; - } - else - { - std :: cout << "User Input Error !" << endl; - getchar(); - exit(1); - } -} - - /******************************************* - * 加密文件 - * - * E_SourceFileName 要加密的文件名 - * E_KEY 密钥 - * E_TargetFileNewName 加密后要保存的文件名 - * - * @return 加密成功或失败的数字表示 - * - * 0 = 加密失败 - * 1 = 加密成功 - ********************************************/ - - int RunEncryptFile(char* E_SFN, char *E_KEY, char *E_KEY2, char *E_KEY3, char* E_TFN) - { - FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 - char buffer[1024]; //缓冲区,用于存放从文件读取的数据 - - int FileByteData, //每次从文件中读取的字节数 - RTNOC, //循环次数 - KeyLength = strlen(E_KEY), //密钥的长度 - KeyLength2 = strlen(E_KEY2), - KeyLength3 = strlen(E_KEY3); - - FilePointerSource = fopen(E_SFN, "rb"); //以二进制方式读取文件 - if(FilePointerSource == NULL) - { - printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", E_SFN); - printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", E_SFN); - getchar(); - return 0; - } - - FilePointerTarget = fopen(E_TFN, "wb"); //以二进制方式写入文件 - if(FilePointerTarget == NULL) - { - printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", FilePointerTarget); - printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", FilePointerTarget); - getchar(); - return 0; - } - -/*加密算法开始*/ -//依次运行三个大型加密模块 -//Run three large encryption modules in turn - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行异或运算 - { - buffer[RTNOC] ^= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递增运算 - { - buffer[RTNOC] += E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递乘运算 - { - buffer[RTNOC] *= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行异或运算 - { - buffer[RTNOC] ^= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递增运算 - { - buffer[RTNOC] += E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递乘运算 - { - buffer[RTNOC] *= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/***********************************************************************************************************************************************************/ - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行异或运算 - { - buffer[RTNOC] ^= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递增运算 - { - buffer[RTNOC] += E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递乘运算 - { - buffer[RTNOC] *= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行异或运算 - { - buffer[RTNOC] ^= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递增运算 - { - buffer[RTNOC] += E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递乘运算 - { - buffer[RTNOC] *= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/***********************************************************************************************************************************************************/ - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行异或运算 - { - buffer[RTNOC] ^= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递增运算 - { - buffer[RTNOC] += E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递乘运算 - { - buffer[RTNOC] *= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行异或运算 - { - buffer[RTNOC] ^= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递增运算 - { - buffer[RTNOC] += E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递乘运算 - { - buffer[RTNOC] *= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/*加密算法结束*/ - - fclose(FilePointerSource); - fclose(FilePointerTarget); - - DeleteFile(E_SFN); - - return 1; - } - - int RunDecryptFile(char* D_SFN, char *D_KEY, char *D_KEY2, char *D_KEY3, char* D_TFN) - { - FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 - char buffer[1024]; //缓冲区,用于存放从文件读取的数据 - - int FileByteData, //每次从文件中读取的字节数 - RTNOC, //循环次数 - KeyLength = strlen(D_KEY), //密钥的长度 - KeyLength2 = strlen(D_KEY2), - KeyLength3 = strlen(D_KEY3); - - FilePointerSource = fopen(D_SFN, "rb"); //以二进制方式读取文件 - if(FilePointerSource == NULL) - { - printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", D_SFN); - printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", D_SFN); - getchar(); - return 0; - } - - FilePointerTarget = fopen(D_TFN, "wb"); //以二进制方式写入文件 - if(FilePointerTarget == NULL) - { - printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", FilePointerTarget); - printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", FilePointerTarget); - getchar(); - return 0; - } - - /******************************************* - * 解密文件 - * - * D_SourceFileName 要解密的文件名 - * D_KEY 密钥 - * D_TargetFileNewName 解密后要保存的文件名 - * - * @return 解密成功或失败的数字表示 - * - * 0 = 解密失败 - * 1 = 解密成功 - ********************************************/ - -/*解密算法开始*/ -//依次运行大型三个解密模块 -//Run three large decryption modules in turn - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行异或运算 - { - buffer[RTNOC] ^= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递减运算 - { - buffer[RTNOC] -= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递除运算 - { - buffer[RTNOC] /= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行异或运算 - { - buffer[RTNOC] ^= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递减运算 - { - buffer[RTNOC] -= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递除运算 - { - buffer[RTNOC] /= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行异或运算 - { - buffer[RTNOC] ^= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递减运算 - { - buffer[RTNOC] -= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递除运算 - { - buffer[RTNOC] /= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/***********************************************************************************************************************************************************/ - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行异或运算 - { - buffer[RTNOC] ^= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递减运算 - { - buffer[RTNOC] -= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递除运算 - { - buffer[RTNOC] /= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行异或运算 - { - buffer[RTNOC] ^= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递减运算 - { - buffer[RTNOC] -= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递除运算 - { - buffer[RTNOC] /= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行异或运算 - { - buffer[RTNOC] ^= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递减运算 - { - buffer[RTNOC] -= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递除运算 - { - buffer[RTNOC] /= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/***********************************************************************************************************************************************************/ - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行异或运算 - { - buffer[RTNOC] ^= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递减运算 - { - buffer[RTNOC] -= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递除运算 - { - buffer[RTNOC] /= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行异或运算 - { - buffer[RTNOC] ^= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递减运算 - { - buffer[RTNOC] -= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递除运算 - { - buffer[RTNOC] /= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行异或运算 - { - buffer[RTNOC] ^= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递减运算 - { - buffer[RTNOC] -= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递除运算 - { - buffer[RTNOC] /= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/*解密算法结束*/ - - fclose(FilePointerSource); - fclose(FilePointerTarget); - - return 1; - } - -//string New_PlainText; //新明文 -//string New_CipherText; //新密文 - - diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..818433e --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Makefile b/Makefile deleted file mode 100644 index e54661a..0000000 --- a/Makefile +++ /dev/null @@ -1,182 +0,0 @@ -#This File Makefile Scrpit - -#Comand Separator Tab Keyboard!!! - -include Makefile.Header - -.PHONY = all beta_version beta_version2 beta_version3 bebug_mode_version bebug_mode_version2 bebug_mode_version3 run.bat run_bebug.bat run run_bebug clean help LINK_OBJECTIVE LINK_OBJECTIVES -all: - - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 01 - - - @make debug_mode_version - - @make debug_mode_version2 - - @make debug_mode_version3 - - - @make beta_version - - @make beta_version2 - - @make beta_version3 - -beta_version: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 02 - - - $(CREATE_FOLDER) $(RELEASE_OBJECTIVES_VERSION_FOLDER) - - $(CREATE_FOLDER) $(RELEASE_EXECUTE_VERSION_FOLDER) - - $(MINGW_CPP) -Wall -O2 -c $(SOURCES_VERSION) -o $(RELEASE_OBJECTIVES_VERSION) - - $(LINK_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION) -o $(RELEASE_EXECUTE_FILE_VERSION) - -beta_version2: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 03 - - - $(CREATE_FOLDER) $(RELEASE_OBJECTIVES_VERSION2_FOLDER) - - $(CREATE_FOLDER) $(RELEASE_EXECUTE_VERSION2_FOLDER) - - $(MINGW_CPP) -Wall -O2 -c $(SOURCES_VERSION2) -o $(RELEASE_OBJECTIVES_VERSION2) - - $(LINK_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION2) -o $(RELEASE_EXECUTE_FILE_VERSION2) - -beta_version3: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 04 - - - $(CREATE_FOLDER) $(RELEASE_OBJECTIVES_VERSION3_FOLDER) - - $(CREATE_FOLDER) $(RELEASE_EXECUTE_VERSION3_FOLDER) - - $(MINGW_CPP) -Wall -O2 -c $(SOURCES_VERSION3) -o $(RELEASE_OBJECTIVES_VERSION3) - - $(LINK_OBJECTIVES) $(RELEASE_OBJECTIVES_VERSION3) -o $(RELEASE_EXECUTE_FILE_VERSION3) - -debug_mode_version: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 05 - - - $(CREATE_FOLDER) $(DEBUG_OBJECTIVES_VERSION_FOLDER) - - $(CREATE_FOLDER) $(DEBUG_EXECUTE_VERSION_FOLDER) - - $(MINGW_DEBUG_CPP) $(SOURCES_VERSION) -o $(DEBUG_OBJECTIVES_VERSION) - - $(LINK_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION) -o $(DEBUG_EXECUTE_FILE_VERSION) - -debug_mode_version2: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 06 - - - $(CREATE_FOLDER) $(DEBUG_OBJECTIVES_VERSION2_FOLDER) - - $(CREATE_FOLDER) $(DEBUG_EXECUTE_VERSION2_FOLDER) - - $(MINGW_DEBUG_CPP) $(SOURCES_VERSION2) -o $(DEBUG_OBJECTIVES_VERSION2) - - $(LINK_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION2) -o $(DEBUG_EXECUTE_FILE_VERSION2) - -debug_mode_version3: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 07 - - - $(CREATE_FOLDER) $(DEBUG_OBJECTIVES_VERSION3_FOLDER) - - $(CREATE_FOLDER) $(DEBUG_EXECUTE_VERSION3_FOLDER) - - $(MINGW_DEBUG_CPP) $(SOURCES_VERSION3) -o $(DEBUG_OBJECTIVES_VERSION3) - - $(LINK_OBJECTIVES) $(DEBUG_OBJECTIVES_VERSION3) -o $(DEBUG_EXECUTE_FILE_VERSION3) - -run.bat: - - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 08 - - @echo @echo off >> run.bat - - @echo.>>run.bat - - @echo cd /d $(RELEASE_EXECUTE_VERSION3_FOLDER) >> run.bat - - @echo.>>run.bat - - @echo start CUI_EncryptDecryptFile_BetaVersion3.exe >> run.bat - - start ".\\run.bat" - -run_debug.bat: - - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 09 - - cd /d ".\\" - - @echo @echo off >> run_debug.bat - - @echo.>>run_debug.bat - - @echo cd /d $(DEBUG_EXECUTE_VERSION3_FOLDER) >> run.bat - - @echo.>>run_debug.bat - - @echo start CUI_EncryptDecryptFile_DebugVersion3.exe >> run_debug.bat - - start ".\\run_debug.bat" - -run: - - - make run.bat - -run_debug: - - - make run_debug.bat - -clean: - - - @cd /d ".\\" - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 10 - - - $(DELETE) $(DEBUG_OBJECTIVES_VERSION) - - $(DELETE) $(DEBUG_OBJECTIVES_VERSION2) - - $(DELETE) $(DEBUG_OBJECTIVES_VERSION3) - - - $(DELETE) $(DEBUG_EXECUTE_FILE_VERSION) - - $(DELETE) $(DEBUG_EXECUTE_FILE_VERSION2) - - $(DELETE) $(DEBUG_EXECUTE_FILE_VERSION3) - - - $(DELETE) $(RELEASE_OBJECTIVES_VERSION) - - $(DELETE) $(RELEASE_OBJECTIVES_VERSION2) - - $(DELETE) $(RELEASE_OBJECTIVES_VERSION3) - - - $(DELETE) $(RELEASE_EXECUTE_FILE_VERSION) - - $(DELETE) $(RELEASE_EXECUTE_FILE_VERSION2) - - $(DELETE) $(RELEASE_EXECUTE_FILE_VERSION3) - - - $(DELETE) ".\\Binary\\Debug\\*.exe" - - $(DELETE) ".\\Binary\\Release\\*.exe" - - $(DELETE) ".\\Objectives\\Debug\\*.o" - - $(DELETE) ".\\Objectives\\Release\\*.o" - - - $(DELETE) ".\\run.bat" - - - $(REMOVE_FOLDER) $(DEBUG_OBJECTIVES_VERSION_FOLDER) - - $(REMOVE_FOLDER) $(DEBUG_OBJECTIVES_VERSION2_FOLDER) - - $(REMOVE_FOLDER) $(DEBUG_OBJECTIVES_VERSION3_FOLDER) - - - $(REMOVE_FOLDER) $(RELEASE_OBJECTIVES_VERSION_FOLDER) - - $(REMOVE_FOLDER) $(RELEASE_OBJECTIVES_VERSION2_FOLDER) - - $(REMOVE_FOLDER) $(RELEASE_OBJECTIVES_VERSION3_FOLDER) - - - $(REMOVE_FOLDER) $(DEBUG_EXECUTE_VERSION_FOLDER) - - $(REMOVE_FOLDER) $(DEBUG_EXECUTE_VERSION2_FOLDER) - - $(REMOVE_FOLDER) $(DEBUG_EXECUTE_VERSION3_FOLDER) - - - $(REMOVE_FOLDER) $(RELEASE_EXECUTE_VERSION_FOLDER) - - $(REMOVE_FOLDER) $(RELEASE_EXECUTE_VERSION2_FOLDER) - - $(REMOVE_FOLDER) $(RELEASE_EXECUTE_VERSION3_FOLDER) - - - $(REMOVE_FOLDER) ".\\Binary\\" - - $(REMOVE_FOLDER) ".\\Objectives\\" - - - $(DELETE) ".\\run_debug.bat" - -help: - - - $(HIDDEN_RUN_MODE) - - $(COMMAND_WINDOW_COLOR) 11 - - @echo make all - - @echo make debug_mode_version (debug) - - @echo make debug_mode_version2 (debug) - - @echo make debug_mode_version3 (debug) - - @echo make beta_version (release) - - @echo make beta_version2 (release) - - @echo make beta_version3 (release) - - @echo make run - - @echo make run_debug - - @echo make clean - - @echo make help \ No newline at end of file diff --git a/Makefile-CbpToMakefileTools/Makefile b/Makefile-CbpToMakefileTools/Makefile deleted file mode 100644 index 7184558..0000000 --- a/Makefile-CbpToMakefileTools/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -#------------------------------------------------------------------------------# -# This makefile was generated by 'cbp2make' tool rev.147 # -#------------------------------------------------------------------------------# - -WORKDIR = %cd% - -CC = gcc.exe -CXX = g++.exe -AR = ar.exe -LD = g++.exe -WINDRES = windres.exe - -INC = -CFLAGS = -Wall -fexceptions -RESINC = -LIBDIR = -LIB = -LDFLAGS = - -INC_DEBUG = $(INC) -CFLAGS_DEBUG = $(CFLAGS) -g -RESINC_DEBUG = $(RESINC) -RCFLAGS_DEBUG = $(RCFLAGS) -LIBDIR_DEBUG = $(LIBDIR) -LIB_DEBUG = $(LIB) -LDFLAGS_DEBUG = $(LDFLAGS) -OBJDIR_DEBUG = ".\\Objectives\\Debug -DEP_DEBUG = -OUT_DEBUG = ".\\Binary\\Debug\\BackDoorProgram-Encrypt_Or_Decrypt_File.exe" - -INC_RELEASE = $(INC) -CFLAGS_RELEASE = $(CFLAGS) -O2 -RESINC_RELEASE = $(RESINC) -RCFLAGS_RELEASE = $(RCFLAGS) -LIBDIR_RELEASE = $(LIBDIR) -LIB_RELEASE = $(LIB) -LDFLAGS_RELEASE = $(LDFLAGS) -s -OBJDIR_RELEASE = ".\\Objectives\\Release -DEP_RELEASE = -OUT_RELEASE = ".\\Binary\\Release\\BackDoorProgram-Encrypt_Or_Decrypt_File.exe" - -OBJ_DEBUG = ".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2\\Main_2 By Twlilght_Yujiang.o" ".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3\\Main_3 By Twlilght_Yujiang.o" $(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version\\Main By Twlilght_Yujiang.o" - -OBJ_RELEASE = ".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2\\Main_2 By Twlilght_Yujiang.o" ".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3\\Main_3 By Twlilght_Yujiang.o" $(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version\\Main By Twlilght_Yujiang.o" - -all: debug release - -clean: clean_debug clean_release - -before_debug: - cmd /c if not exist Binary\\Debug mkdir Binary\\Debug - cmd /c if not exist ".\\Objectives\\Debug)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version" mkdir $(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version" - cmd /c if not exist ".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2" mkdir $(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2" - cmd /c if not exist ".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3" mkdir $(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3" - -after_debug: - -debug: before_debug out_debug after_debug - -out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG) - $(LD) $(LIBDIR_DEBUG) -o $(OUT_DEBUG) $(OBJ_DEBUG) $(LDFLAGS_DEBUG) $(LIB_DEBUG) - -$(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version\\Main By Twlilght_Yujiang.o: [Encrypt_Or_Decrypt_File] Source Code\\Beta Version\\Main By Twlilght_Yujiang.cpp - $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c ".\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version\\Main By Twlilght_Yujiang.cpp" -o $(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version\\Main By Twlilght_Yujiang.o" - -$(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3\\Main_3 By Twlilght_Yujiang.o: [Encrypt_Or_Decrypt_File] Source Code\\Beta Version3\\Main_3 By Twlilght_Yujiang.cpp - $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c ".\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3\\Main_3 By Twlilght_Yujiang.cpp" -o $(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3\\Main_3 By Twlilght_Yujiang.o" - -$(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2\\Main_2 By Twlilght_Yujiang.o: [Encrypt_Or_Decrypt_File] Source Code\\Beta Version2\\Main_2 By Twlilght_Yujiang.cpp - $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c ".\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2\\Main_2 By Twlilght_Yujiang.cpp" -o $(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2\\Main_2 By Twlilght_Yujiang.o" - -clean_debug: - cmd /c del /f $(OBJ_DEBUG) $(OUT_DEBUG) - cmd /c rmdir /s /q Binary\\Debug - cmd /c rmdir /s /q $(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version" - cmd /c rmdir /s /q $(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2" - cmd /c rmdir /s /q $(OBJDIR_DEBUG)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3" - -before_release: - cmd /c if not exist Binary\\Release mkdir Binary\\Release - cmd /c if not exist ".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version" mkdir $(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version" - cmd /c if not exist ".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2" mkdir $(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2" - cmd /c if not exist ".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3" mkdir $(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3" - -after_release: - -release: before_release out_release after_release - -out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE) - $(LD) $(LIBDIR_RELEASE) -o $(OUT_RELEASE) $(OBJ_RELEASE) $(LDFLAGS_RELEASE) $(LIB_RELEASE) - -$(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version\\Main By Twlilght_Yujiang.o: [Encrypt_Or_Decrypt_File] Source Code\\Beta Version\\Main By Twlilght_Yujiang.cpp - $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ".\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version\\Main By Twlilght_Yujiang.cpp" -o $(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version\\Main By Twlilght_Yujiang.o" - -$(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2\\Main_2 By Twlilght_Yujiang.o: [Encrypt_Or_Decrypt_File] Source Code\\Beta Version2\\Main_2 By Twlilght_Yujiang.cpp - $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ".\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2\\Main_2 By Twlilght_Yujiang.cpp" -o $(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2\\Main_2 By Twlilght_Yujiang.o" - -$(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3\\Main_3 By Twlilght_Yujiang.o: [Encrypt_Or_Decrypt_File] Source Code\\Beta Version3\\Main_3 By Twlilght_Yujiang.cpp - $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ".\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3\\Main_3 By Twlilght_Yujiang.cpp" -o $(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3\\Main_3 By Twlilght_Yujiang.o" - -clean_release: - cmd /c del /f $(OBJ_RELEASE) $(OUT_RELEASE) - cmd /c rmdir /s /q Binary\\Release - cmd /c rmdir /s /q $(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version" - cmd /c rmdir /s /q $(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version2" - cmd /c rmdir /s /q $(OBJDIR_RELEASE)\\[Encrypt_Or_Decrypt_File] Source Code\\Beta Version3" - -.PHONY: before_debug after_debug clean_debug before_release after_release clean_release - diff --git a/Makefile.Header b/Makefile.Header deleted file mode 100644 index 4ab2cf7..0000000 --- a/Makefile.Header +++ /dev/null @@ -1,52 +0,0 @@ -#This File Makefile Scrpit Header - -#Workspace File - -HIDDEN_RUN_MODE=@echo off -COMMAND_WINDOW_COLOR=@color - -DELETE=@del /s /f /q -CREATE_FOLDER=@mkdir -REMOVE_FOLDER=@rmdir /s /q - -MINGW_CPP=@g++ -Wall -O2 -c -MINGW_DEBUG_CPP=@g++ -Wall -fexceptions -g -c -LINK_OBJECTIVES=g++ -static - -SOURCES_VERSION=".\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\Main_By_Twlilght_Yujiang.cpp" -SOURCES_VERSION2=".\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\Main_2_By_Twlilght_Yujiang.cpp" -SOURCES_VERSION3=".\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\Main_3_By_Twlilght_Yujiang.cpp" - -DEBUG_OBJECTIVES_VERSION=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\Main_By_Twlilght_Yujiang.o" -DEBUG_OBJECTIVES_VERSION2=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\Main_2_By_Twlilght_Yujiang.o" -DEBUG_OBJECTIVES_VERSION3=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\Main_3_By_Twlilght_Yujiang.o" - -DEBUG_EXECUTE_FILE_VERSION=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\CUI_EncryptDecryptFile_DebugVersion.exe" -DEBUG_EXECUTE_FILE_VERSION2=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\CUI_EncryptDecryptFile_DebugVersion2.exe" -DEBUG_EXECUTE_FILE_VERSION3=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\CUI_EncryptDecryptFile_DebugVersion3.exe" - -RELEASE_OBJECTIVES_VERSION=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\Main_By_Twlilght_Yujiang.o" -RELEASE_OBJECTIVES_VERSION2=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\Main_2_By_Twlilght_Yujiang.o" -RELEASE_OBJECTIVES_VERSION3=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\Main_3_By_Twlilght_Yujiang.o" - -RELEASE_EXECUTE_FILE_VERSION=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\CUI_EncryptDecryptFile_BetaVersion.exe" -RELEASE_EXECUTE_FILE_VERSION2=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\CUI_EncryptDecryptFile_BetaVersion2.exe" -RELEASE_EXECUTE_FILE_VERSION3=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\CUI_EncryptDecryptFile_BetaVersion3.exe" - -#Make Workspace Folder - -DEBUG_OBJECTIVES_VERSION_FOLDER=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\" -DEBUG_OBJECTIVES_VERSION2_FOLDER=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\" -DEBUG_OBJECTIVES_VERSION3_FOLDER=".\\Objectives\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\" - -RELEASE_OBJECTIVES_VERSION_FOLDER=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\" -RELEASE_OBJECTIVES_VERSION2_FOLDER=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\" -RELEASE_OBJECTIVES_VERSION3_FOLDER=".\\Objectives\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\" - -DEBUG_EXECUTE_VERSION_FOLDER=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\" -DEBUG_EXECUTE_VERSION2_FOLDER=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\" -DEBUG_EXECUTE_VERSION3_FOLDER=".\\Binary\\Debug\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\" - -RELEASE_EXECUTE_VERSION_FOLDER=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version\\" -RELEASE_EXECUTE_VERSION2_FOLDER=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version2\\" -RELEASE_EXECUTE_VERSION3_FOLDER=".\\Binary\\Release\\[Encrypt_Or_Decrypt_File]-Source-Code\\Beta-Version3\\" diff --git a/Objectives/Debug/EODF/Beta-Version/Main_EODF_By_TDOM.o b/Objectives/Debug/EODF/Beta-Version/Main_EODF_By_TDOM.o new file mode 100644 index 0000000..a859a44 Binary files /dev/null and b/Objectives/Debug/EODF/Beta-Version/Main_EODF_By_TDOM.o differ diff --git a/Objectives/Debug/EODF/Beta-Version2/Main_EODF2_By_TDOM.o b/Objectives/Debug/EODF/Beta-Version2/Main_EODF2_By_TDOM.o new file mode 100644 index 0000000..8329ad2 Binary files /dev/null and b/Objectives/Debug/EODF/Beta-Version2/Main_EODF2_By_TDOM.o differ diff --git a/Objectives/Debug/EODF/Beta-Version3/Main_EODF3_By_TDOM.o b/Objectives/Debug/EODF/Beta-Version3/Main_EODF3_By_TDOM.o new file mode 100644 index 0000000..8e4a2f4 Binary files /dev/null and b/Objectives/Debug/EODF/Beta-Version3/Main_EODF3_By_TDOM.o differ diff --git a/Objectives/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.o b/Objectives/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.o deleted file mode 100644 index 667c754..0000000 Binary files a/Objectives/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.o and /dev/null differ diff --git a/Objectives/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.o b/Objectives/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.o deleted file mode 100644 index d5ae5ad..0000000 Binary files a/Objectives/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.o and /dev/null differ diff --git a/Objectives/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.o b/Objectives/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.o deleted file mode 100644 index 8f414c9..0000000 Binary files a/Objectives/Debug/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.o and /dev/null differ diff --git a/Objectives/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.o b/Objectives/Release/EODF/Beta-Version/Main_EODF_By_TDOM.o similarity index 81% rename from Objectives/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.o rename to Objectives/Release/EODF/Beta-Version/Main_EODF_By_TDOM.o index f72af9e..44670ee 100644 Binary files a/Objectives/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.o and b/Objectives/Release/EODF/Beta-Version/Main_EODF_By_TDOM.o differ diff --git a/Objectives/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.o b/Objectives/Release/EODF/Beta-Version2/Main_EODF2_By_TDOM.o similarity index 81% rename from Objectives/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.o rename to Objectives/Release/EODF/Beta-Version2/Main_EODF2_By_TDOM.o index cf5f7b7..bd76c82 100644 Binary files a/Objectives/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.o and b/Objectives/Release/EODF/Beta-Version2/Main_EODF2_By_TDOM.o differ diff --git a/Objectives/Release/EODF/Beta-Version3/Main_EODF3_By_TDOM.o b/Objectives/Release/EODF/Beta-Version3/Main_EODF3_By_TDOM.o new file mode 100644 index 0000000..5c3a604 Binary files /dev/null and b/Objectives/Release/EODF/Beta-Version3/Main_EODF3_By_TDOM.o differ diff --git a/Objectives/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.o b/Objectives/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.o deleted file mode 100644 index 217be90..0000000 Binary files a/Objectives/Release/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.o and /dev/null differ diff --git a/README.md b/README.md index ddf6067..990bfe7 100644 --- a/README.md +++ b/README.md @@ -1,73 +1,102 @@ ------------------------------------------------------------------------------------------------------------------------- +# About the c-plus-plus code project -English +--- -1.At present this procedure, only need to do some landscaping, as well as detailed adjustments to the manual. +## English -2.Do not need to do much change. +### 1.At present this procedure, only need to do some landscaping, as well as detailed adjustments to the manual. -3.Of course, if you need to change it. Give me a better suggestion, let me write this procedure. +### 2.So, do not need to do much change for code. +### 3.Of course, if you need me to change code it. 鈼 +### Please give me a better suggestion, let me write this procedure(program). 鈼 +### 4. Sometimes the test version of the project (Preview test version code project), there will be some new test functions and change the code structure. 鈻 +### If the code (75%) is changed too much, it may not be compatible with the previous version. 鈻 +### Although, they may be problematic code or the code that does not fully implement my idea. However, this is my new attempt to upgrade the code every time.(Maybe, what can I do it this?) 鈻 +### This will make me progress in programming techniques. I share my the little achievements of programming made me feel satisfied. 鈻 +### In addition, I very much welcome everyone to help me. For those who can give me, financial sponsorship and technical support, I would like to express my strong gratitude and thank you for your attention and support! 鈼 -This code repository consists of [Twlilght-Dream-Of-Magic] Twlilght_Yujiang author, compiled and built! -IDE: Integrated development environment +#### This code repository consists of [Twilight-Dream-Of-Magic] author, compiled and built! -It is best not to use Code Block IDE, to build this project! +#### IDE: Integrated development environment +#### ~~It is best not to use Code Block IDE, to build this project!~~ +#### ~~Although i provided the [* .cbp] file! (Code Block Project File)~~ -Best to use Makefile build project! -If you need to view my Makefile help, the command line input [make help]. -This Makefile file +#### The best option is to use Makefile to build this project! -Applicable to (Microsoft Windows) system (already completed, the code has BUG please Github message) +#### If you need to view the script file for my provided. -Applicable to (Linux) system (still in plan .......) +#### (Makefile) command help information, please use the command line to enter `make help` in the same directory of this file. -If you want to use the IDE to build this project, please distinguish between each version! +#### This Makefile file -This warehouse, each version of the project folder, please create a new IDE project file, and then associated! +#### Applicable to (Microsoft Windows) system (Already completed, the code has BUG please create from Github issues message) ------------------------------------------------------------------------------------------------------------------------- +#### Applicable to (Linux) system (Still in plan .......) -Chinese -1.鐩墠杩欎釜绋嬪簭锛屽彧闇瑕佸仛涓浜涚編鍖栵紝杩樻湁璇存槑涔︾殑璇︾粏璋冩暣銆 -2.涓嶉渶瑕佸仛浠涔堝お澶х殑鏀瑰姩銆 +#### If you want to use the IDE to build this project, please distinguish between each version! -3.褰撶劧锛屽鏋滀綘闇瑕佹敼鍔ㄧ殑璇濄傜粰鎴戞洿濂界殑寤鸿锛岃鎴戝幓缂栧啓杩欎釜绋嬪簭銆 +#### This repository (knowledge warehouse), each version of the project folder, please create a new IDE project file, and then associated! +--- +# 鍏充簬杩欎釜C++浠g爜椤圭洰 -杩欎釜浠g爜浠撳簱鐢 [Twlilght-Dream-Of-Magic] Twlilght_Yujiang 浣滆咃紝缂栬瘧鍜屾瀯寤! +## Chinese -IDE 锛 闆嗘垚寮鍙戠幆澧 +### 1.鐩墠杩欎釜绋嬪簭锛屽彧闇瑕佸仛涓浜涚編鍖栵紝杩樻湁璇存槑涔︾殑璇︾粏璋冩暣銆 -鏈濂戒笉瑕佷娇鐢–ode Block IDE锛屾潵鏋勫缓杩欎釜宸ョ▼锛 +### 2.鎵浠ワ紝涓嶉渶瑕佷负浠g爜鍋氬お澶氭敼鍙樸 +### 3.褰撶劧锛屽鏋滀綘闇瑕佹垜鏀瑰姩浠g爜鐨勮瘽銆 鈼 +### 璇风粰鎴戞洿濂界殑寤鸿锛岃鎴戝幓缂栧啓杩欎釜绋嬪簭銆 鈼 +### 4.鏈夋椂鍊欐祴璇曠増鏈」鐩(Preview test version code project)锛屽皢浼氭湁涓浜涙柊鐨勬祴璇曞姛鑳藉拰鏀瑰彉浠g爜缁撴瀯銆 鈻 +### 濡傛灉鍙戠敓浜嗗お澶ф敼鍙樼殑浠g爜(75%)锛屼篃璁镐細璁╁畠涓庝互鍓嶇増鏈笉鍏锋湁鍏煎鎬с 鈻 +### 灏界锛屽畠浠彲鑳芥槸鏈夐棶棰樼殑浠g爜鎴栬呮病鏈夋妸鎴戠殑鎯虫硶鏉ュ畬鍏ㄥ疄鐜扮殑浠g爜銆傜劧鑰岋紝杩欓兘鏄垜姣忎竴娆″崌绾т唬鐮佺殑鏂板皾璇曘(涔熻锛屾垜鑳藉鍋氬埌鐨勶紵) 鈻 +### 杩欎細璁╂垜鏈夌紪绋嬫妧鏈殑杩涙锛屾垜鍒嗕韩鎴戠殑缂栫▼灏忔垚灏憋紝浣挎垜寰楀埌婊¤冻鐨勬劅瑙夈 鈻 +### 鍙﹀锛屾垜闈炲父娆㈣繋澶у鏉ュ府鍔╂垜锛屽浜庨偅浜涜兘澶熺粰浜堟垜锛岃祫閲戣禐鍔╁拰鎶鏈敮鎸佺殑浜轰滑锛屾垜琛ㄧず寮虹儓鐨勬劅璋紝璋㈣阿澶у鐨勫叧娉ㄥ拰鏀寔! 鈽 -鏈濂戒娇鐢∕akefile鏋勫缓宸ョ▼! -濡傛灉闇瑕侊紝鏌ョ湅鎴戠殑Makefile甯姪锛屽懡浠よ杈撳叆[make help] -杩欎釜Makefile鏂囦欢 +#### 杩欎釜浠g爜浠撳簱鐢 [Twilight-Dream-Of-Magic] 浣滆咃紝缂栬瘧鍜屾瀯寤! -閫傜敤浜(Microsoft Windows)绯荤粺 (宸茬粡瀹屾垚锛屼唬鐮佹湁BUG璇峰湪Github涓婄暀瑷) +#### IDE 锛 闆嗘垚寮鍙戠幆澧 -閫傜敤浜(Linux)绯荤粺 (杩樺湪璁″垝涓.......) +#### ~~鏈濂戒笉瑕佷娇鐢–ode Block IDE锛屾潵鏋勫缓杩欎釜宸ョ▼锛亊~ +#### ~~铏界劧鎴戞彁渚涗簡[*.cbp]鏂囦欢锛(Code Block Project File)~~ -濡傛灉浣犺浣跨敤IDE鏋勫缓杩欎釜宸ョ▼锛岃鍖哄垎姣忎竴涓増鏈紒 -杩欎釜浠撳簱锛屾瘡涓涓増鏈殑宸ョ▼鏂囦欢澶癸紝璇锋柊寤轰竴涓狪DE宸ョ▼鏂囦欢锛岀劧鍚庡叧鑱! +#### 鏈濂界殑閫夋嫨锛屾槸浣犱娇鐢∕akefile鏋勫缓杩欎釜宸ョ▼! ------------------------------------------------------------------------------------------------------------------------- +#### 濡傛灉浣犻渶瑕佹煡鐪嬶紝鎴戞彁渚涚殑鑴氭湰鏂囦欢銆 + +#### (Makefile)鐨勫懡浠ゅ府鍔╀俊鎭紝璇峰湪杩欎釜鏂囦欢鐨勫悓涓涓洰褰曚笅锛屼娇鐢ㄥ懡浠よ杈撳叆 `make help` + + + +#### 杩欎釜Makefile鏂囦欢 + +#### 閫傜敤浜(Microsoft Windows)绯荤粺 (宸茬粡瀹屾垚锛屼唬鐮佹湁BUG璇峰湪Github涓婂垱寤洪棶棰樼暀瑷) + +#### 閫傜敤浜(Linux)绯荤粺 (杩樺湪璁″垝涓.......) + + + +#### 濡傛灉浣犺浣跨敤IDE鏋勫缓杩欎釜宸ョ▼锛岃鍖哄垎姣忎竴涓増鏈紒 + +#### 杩欎釜鐭ヨ瘑搴(鐭ヨ瘑浠撳簱)锛屾瘡涓涓増鏈殑宸ョ▼鏂囦欢澶癸紝璇锋柊寤轰竴涓狪DE宸ョ▼鏂囦欢锛岀劧鍚庡叧鑱! + +--- diff --git a/Test_Binary/Alpha-Version3.1/CUI_EncryptDecryptFile_TestVersion3-1.exe b/Test_Binary/Alpha-Version3.1/CUI_EncryptDecryptFile_TestVersion3-1.exe new file mode 100644 index 0000000..8f972ae Binary files /dev/null and b/Test_Binary/Alpha-Version3.1/CUI_EncryptDecryptFile_TestVersion3-1.exe differ diff --git a/Test_Binary/Alpha-Version3.1/CUI_EncryptDecryptFile_TestVersion3-1.objective-binary b/Test_Binary/Alpha-Version3.1/CUI_EncryptDecryptFile_TestVersion3-1.objective-binary new file mode 100644 index 0000000..dd78c89 Binary files /dev/null and b/Test_Binary/Alpha-Version3.1/CUI_EncryptDecryptFile_TestVersion3-1.objective-binary differ diff --git a/Test_Binary/Alpha-Version3.1/CUI_EncryptDecryptFile_TestVersion3-1_StaticLink.exe b/Test_Binary/Alpha-Version3.1/CUI_EncryptDecryptFile_TestVersion3-1_StaticLink.exe new file mode 100644 index 0000000..defd4ac Binary files /dev/null and b/Test_Binary/Alpha-Version3.1/CUI_EncryptDecryptFile_TestVersion3-1_StaticLink.exe differ diff --git a/Test_Binary/Alpha-Version3.1/[Note Information] EODF CUI_Program file crypto function(Version 3.1).txt b/Test_Binary/Alpha-Version3.1/[Note Information] EODF CUI_Program file crypto function(Version 3.1).txt new file mode 100644 index 0000000..4a29bac --- /dev/null +++ b/Test_Binary/Alpha-Version3.1/[Note Information] EODF CUI_Program file crypto function(Version 3.1).txt @@ -0,0 +1,91 @@ +锘縍EADME + +Chinese: +铏界劧锛屾垜鍙戝竷浜嗚繖涓紙Test Alpha 3.1锛夌増鏈殑绋嬪簭锛屼絾鏄紝瀹冧笉鍏煎浣跨敤鏃х増鏈殑鍔犲瘑绠楁硶鐢熸垚鐨勫姞瀵嗘枃浠讹紝鐒跺悗鎶婂畠瑙e瘑姝g‘銆 +鍥犳锛屾柊鐗堟湰鐨勭▼搴忓畠涓嶄娇鐢ㄦ棫鐗堟湰鐨勫姞瀵嗙畻娉曞拰瑙e瘑绠楁硶銆傛墍浠ワ紝鐜板湪浣犳湁2绉(鍔犲瘑鍜岃В瀵)绠楁硶鐨勬枃浠跺瘑鐮侀攣浜嗐傛垜甯屾湜锛屼綘浠枩娆㈣繖涓娆$▼搴忓崌绾с +褰撶劧锛岀幇鍦ㄥ紑鍙戠殑杩欎釜绋嬪簭(CUI_EODF 鎴 GUI_EODF)锛岃繍琛岀殑骞冲彴鏄疢icrosoft Windows绯荤粺銆 +濡傛灉锛屼綘浠兂瑕佹垜缁х画鍧氭寔锛屽幓鐮旂┒绋嬪簭鐨勬簮浠g爜鍜屽涔犺绠楁満璇█锛屽啀鏉ュ紑鍙戣繖涓」鐩殑鍏朵粬绯荤粺骞冲彴锛屾瘮濡傜Щ妞嶅埌Linux鐗堟湰鐨勭▼搴忋 +璇峰敖閲忓彲鑳界殑甯姪鎴戠殑寮鍙戯紝璇峰湪鎴戠殑github缃戠珯绌洪棿涓婄暀瑷銆傝阿璋綘浠殑鏀寔 +骞朵笖锛岀▼搴忎粠 3.0 (Beta preview edition)鐗堟湰锛屽崌绾у埌 3.1 (Alpha preview edition)鐗堟湰銆 +涓嶈繃杩樻槸闇瑕佹祴璇曪紝鏈鍚庣殑鏇存敼鏄瘮杈冨ぇ鐨勩 +浣滆呮湰浜(Twilight-Dream-Of-Magic)宸茬粡璇曢獙鎴愬姛锛屾柊鐨勫姞瀵嗗拰瑙e瘑鐨勬牳蹇冪畻娉曪紝瀵逛簬鍗曞瓧鑺傛枃浠舵祦鏁版嵁鍜屽瘑閽ヤ箣闂达紝鏉ヨ繘琛屽鐞嗚绠楋紝绋嬪簭鍙樺緱姣旇緝鏈夌敤鍜岃〃鐜板緢濂姐 +鍥犱负鏇存柊涔嬪悗锛岃淇濇姢鐨勬枃浠剁殑瀹夊叏鎬ф彁楂樹竴浜涳紝琚鐞嗘枃浠剁殑瀵嗘枃鏁版嵁淇℃伅鏇村浜嗐備笉杩囷紝鏂囦欢鐨勫鐞嗛熷害杩樻槸寰堟參銆 + +English: +Although, I have released this (Test Alpha 3.1) version of the program, but it is not compatible with the old version of the encryption algorithm generated encrypted files, and then decrypt it correctly. +Therefore, the new version of the program it does not use the old version of the encryption algorithm and decryption algorithm. So, Now you have 2 kinds of (encryption and decryption) algorithm of the file password lock. I hope you like this one time program upgrade. +Of course, the program that is now developed (CUI_EODF or GUI_EODF) is running on a Microsoft Windows system. +If you want me to continue, research the source code of the program and learn the computer language, and then develop other system platforms for the project, such as the program ported to the Linux version. +Please try your best to help me with the development, please leave a message on my GitHub website space. Thank you for your support. +Also, the program changes from the Beta version name tag to Alpha, which is upgraded from 3.0 (Beta preview edition) to 3.1 (Alpha preview edition). +However, testing is still required, and the final change is relatively large. +The author himself (Twilight-dream-magic) has successfully experimented with the new encryption and decryption core algorithm for processing computations between Single-byte file stream data and keys, and the program becomes more useful and well behaved. +Because after the update, the security of the protected file improved a little more, the encrypted data of the file processed more information. However, the file processing speed is still very slow. + + +This My File Encryption Core Function + +Logical method + +Use Key + +Data /= Key +Data += Key +Data *= Key +Data -= Key + +Use Key2 + +Data *= Key2 +Data -= Key2 +Data /= Key2 +Data += Key2 + +Use Key3 + +Data -= Key3 +Data /= Key3 +Data += Key3 +Data *= Key3 + +Use Key4 + +Data += Key4 +Data *= Key4 +Data -= Key4 +Data /= Key4 + + + +This My File Decryption Core Function + +Logical method + +Use Key + +Data /= Key +Data -= Key +Data *= Key +Data += Key + +Use Key2 + +Data *= Key +Data += Key +Data /= Key +Data -= Key + +Use Key3 + +Data += Key +Data /= Key +Data -= Key +Data *= Key + +Use Key4 + +Data -= Key +Data *= Key +Data += Key +Data /= Key + diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/EODF_By_TDOM.hpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/EODF_By_TDOM.hpp new file mode 100644 index 0000000..b77defb --- /dev/null +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/EODF_By_TDOM.hpp @@ -0,0 +1,150 @@ +/******************************************* +* 加密文件 +* +* E_SourceFileName 要加密的文件名 +* E_KEY 密钥 +* E_TargetFileNewName 加密后要保存的文件名 +* +* @return 加密成功或失败的数字表示 +* +* 0 = 加密失败 +* 1 = 加密成功 +********************************************/ + + int RunEncryptFile(char *E_SourceFileName, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_TargetFileNewName) + { + FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 + char buffer[1024]; //缓冲区,用于存放从文件读取的数据 + + int FileByteData, //每次从文件中读取的字节数 + RTNOC, //循环次数 + KeyLength = strlen(E_KEY), //密钥的长度 + KeyLength2 = strlen(E_KEY2), + KeyLength3 = strlen(E_KEY3); + + FilePointerSource = fopen(E_SourceFileName, "rb"); //以二进制方式读取文件 + if(FilePointerSource== NULL) + { + printf("file[%s]failed to open, please check whether the file path and name are entered correctly! \n", E_SourceFileName); + printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", E_SourceFileName); + getchar(); + return 0; + } + + FilePointerTarget = fopen(E_TargetFileNewName, "wb"); //以二进制方式写入文件 + if(FilePointerTarget== NULL) + { + printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", E_TargetFileNewName); + printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", E_TargetFileNewName); + getchar(); + return 0; + } +/*加密算法开始*/ + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 + { + buffer[RTNOC] ^= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 + { + buffer[RTNOC] ^= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 + { + buffer[RTNOC] ^= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +/*加密算法结束*/ + + fclose(FilePointerSource); + fclose(FilePointerTarget); + + return 1; + } + + int RunDecryptFile(char *D_SourceFileName, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_TargetFileNewName) + { + FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 + char buffer[1024]; //缓冲区,用于存放从文件读取的数据 + + int FileByteData, //每次从文件中读取的字节数 + RTNOC, //循环次数 + KeyLength = strlen(D_KEY), //密钥的长度 + KeyLength2 = strlen(D_KEY2), + KeyLength3 = strlen(D_KEY3); + + FilePointerSource = fopen(D_SourceFileName, "rb"); //以二进制方式读取文件 + if(FilePointerSource== NULL) + { + printf("file[%s]failed to open, please check whether the file path and name are entered correctly! \n", D_SourceFileName); + printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", D_SourceFileName); + getchar(); + return 0; + } + + FilePointerTarget = fopen(D_TargetFileNewName, "wb"); //以二进制方式写入文件 + if(FilePointerTarget== NULL) + { + printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", D_TargetFileNewName); + printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", D_TargetFileNewName); + getchar(); + return 0; + } + +/******************************************* +* 解密文件 +* +* D_SourceFileName 要解密的文件名 +* D_KEY 密钥 +* D_TargetFileNewName 解密后要保存的文件名 +* +* @return 解密成功或失败的数字表示 +* +* 0 = 解密失败 +* 1 = 解密成功 +********************************************/ + +/*解密算法开始*/ + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 + { + buffer[RTNOC] ^= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 + { + buffer[RTNOC] ^= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 + { + buffer[RTNOC] ^= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +/*解密算法结束*/ + + fclose(FilePointerSource); + fclose(FilePointerTarget); + + return 1; + } \ No newline at end of file diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.cpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.cpp deleted file mode 100644 index b17d2c7..0000000 --- a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -Read Me - About This Source Code File - -Chinese中文: -计算机语言类型: C++ -程序文件名: Twlilght_Yujiang_File_Lock -程序平台类型: Windows 命令行控制台 -程序实际作用: 文件对称式加密解密 -版本: Beta 1.0 -源代码修改时间: 2017-8-1 -作者:Twlilght_Yujiang - -English英文: -Chinese -Computer Language Type: C++ -Program File Name: Twlilght_Yujiang_File_Lock -Program Platform Type: Windows Command Line Console -The actual role of the program: file symmetric encryption and decryption -Version: Beta 1.0 -Source code modified by: 2017-8-1 -Author: Twlilght_Yujiang -*****************************************************************************/ - -#include -#include //标准输入输出函数 -#include //标准库函数 -#include //字符串处理函数 -#include - -using namespace std; - -//typedef unsigned char byte; - -int RunEncryptFile(char *E_SourceFileName, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_TargetFileNewName); -int RunDecryptFile(char *D_SourceFileName, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_TargetFileNewName); - -int main() -{ - string Load_User_Keyboard_Input; - - std :: cout << "----------" << endl; - std :: cout << "Enter 1 EncryptFile" << endl; - std :: cout << "Enter 2 DecryptFile" << endl; - std :: cout << "Enter 3 Exit Program" << endl; - std :: cout << "----------" << endl; - std :: cout << "" << endl; - std :: cout << "System:Input And Output/Enter>"; - - std :: cin >> Load_User_Keyboard_Input; - getchar(); - - if(Load_User_Keyboard_Input == "1") - { - char E_SourceFileName[4096], // 加密的文件名 - E_TargetFileNewName[4096]; // 加密后要保存的文件名 - - char E_KEY[128], //File (Encryption or Encrypted) key 文件加密密钥 - E_KEY2[128], - E_KEY3[128]; - - printf("Please input >>> the source file name\n(Contains the directory name):\n"); - printf("输入要加密的文件名,[C:\]不要输入空格(含路径):\n"); - scanf("%s", E_SourceFileName); - - printf("\n"); - printf("输入(长度小于128)密钥,不要输入空格:\n"); //密钥是用户自己定义的,(长度小于128)。可以随意给需要加密的文件添加密钥 - printf("Please input >>> the key,Do not enter spaces!\n(length less than 128):\n"); - scanf("%s", E_KEY); - - printf("\n"); - printf("输入(长度小于128)密钥2,不要输入空格:\n"); //密钥是用户自己定义的,(长度小于128)。可以随意给需要加密的文件添加密钥 - printf("Please input >>> the key2,Do not enter spaces!\n(length less than 128):\n"); - scanf("%s", E_KEY2); - - printf("\n"); - printf("输入(长度小于128)密钥3,不要输入空格:\n"); //密钥是用户自己定义的,(长度小于128)。可以随意给需要加密的文件添加密钥 - printf("Please input >>> the key3,Do not enter spaces!\n(length less than 128):\n"); - scanf("%s", E_KEY3); - - printf("\n"); - printf("Please input >>> the target file new name(Contains the directory name):\n"); - printf("加密后的文件名,不要输入空格(含路径):\n"); //给加密后的文件命名,并保存 - scanf("%s",E_TargetFileNewName); - - printf("Please wait, read and write in the file......\n"); - printf("请等待,文件读写中......\n"); - getchar(); - - if(RunEncryptFile(E_SourceFileName, E_KEY, E_KEY2, E_KEY3, E_TargetFileNewName)) - { - printf("恭喜你,文件[%s]加密成功,保存在[%s]。\n", E_SourceFileName, E_TargetFileNewName); - printf("Congratulations, the file [%s] is encrypted successfully, saved in [%s]. \n", E_SourceFileName, E_TargetFileNewName); - getchar(); - system("pause"); - return 0; - } - } - if(Load_User_Keyboard_Input == "2") - { - char D_SourceFileName[4096]; //源文件名 - char D_TargetFileNewName[4096]; //目标文件新名称 - - char D_KEY[128], //File (Decryption or Decrypted) key 文件解密密钥 - D_KEY2[128], - D_KEY3[128]; - - printf("\n"); - printf("Please input >>> the source file name\n(Contains the directory name):\n"); - printf("输入要解密的文件名,[C:\]不要输入空格(含路径):\n"); - scanf("%s", D_SourceFileName); - - printf("\n"); - printf("输入(长度小于128)密钥,不要输入空格:\n"); //密钥是用户自己定义的,可以随意给需要解密的文件输入密钥 - printf("Please input >>> the key3,Do not enter spaces!\n(length less than 128):\n"); - scanf("%s", D_KEY); - - printf("\n"); - printf("输入(长度小于128)密钥2,不要输入空格:\n"); - printf("Please input >>> the key2,Do not enter spaces!\n(length less than 128):\n"); - scanf("%s", D_KEY2); - - printf("\n"); - printf("输入(长度小于128)密钥3,不要输入空格:\n"); - printf("Please input >>> the key,Do not enter spaces!\n(length less than 128):\n"); - scanf("%s", D_KEY3); - - printf("\n"); - printf("Please input >>> the target file new name(Contains the directory name):\n"); - printf("解密后的文件名,不要输入空格(含路径):\n"); //给解密后的文件命名,并保存 - scanf("%s",D_TargetFileNewName); - - printf("Please wait, read and write in the file......\n"); - printf("请等待,文件读写中......\n"); - getchar(); - - if(RunDecryptFile(D_SourceFileName, D_KEY, D_KEY2, D_KEY3, D_TargetFileNewName)) - { - printf("恭喜你,文件[%s]解密成功,保存在[%s]。\n", D_SourceFileName, D_TargetFileNewName); - printf("Congratulations, the file [%s] is decrypted successfully, saved in [%s]. \n", D_SourceFileName, D_TargetFileNewName); - getchar(); - system("pause"); - return 0; - } - } - - if(Load_User_Keyboard_Input == "3") - { - return 0; - } - else - { - std :: cout << "User Input Error !" << endl; - getchar(); - exit(1); - } -} - -#include "Main_By_Twlilght_Yujiang.hpp" \ No newline at end of file diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.hpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.hpp deleted file mode 100644 index 3b2ab34..0000000 --- a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_By_Twlilght_Yujiang.hpp +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************* -* 加密文件 -* -* E_SourceFileName 要加密的文件名 -* E_KEY 密钥 -* E_TargetFileNewName 加密后要保存的文件名 -* -* @return 加密成功或失败的数字表示 -* -* 0 = 加密失败 -* 1 = 加密成功 -********************************************/ - - int RunEncryptFile(char *E_SourceFileName, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_TargetFileNewName) - { - FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 - char buffer[1024]; //缓冲区,用于存放从文件读取的数据 - - int FileByteData, //每次从文件中读取的字节数 - RTNOC, //循环次数 - KeyLength = strlen(E_KEY), //密钥的长度 - KeyLength2 = strlen(E_KEY2), - KeyLength3 = strlen(E_KEY3); - - FilePointerSource = fopen(E_SourceFileName, "rb"); //以二进制方式读取文件 - if(FilePointerSource== NULL) - { - printf("file[%s]failed to open, please check whether the file path and name are entered correctly! \n", E_SourceFileName); - printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", E_SourceFileName); - getchar(); - return 0; - } - - FilePointerTarget = fopen(E_TargetFileNewName, "wb"); //以二进制方式写入文件 - if(FilePointerTarget== NULL) - { - printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", FilePointerTarget); - printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", FilePointerTarget); - getchar(); - return 0; - } -/*加密算法开始*/ - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 - { - buffer[RTNOC] ^= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 - { - buffer[RTNOC] ^= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 - { - buffer[RTNOC] ^= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/*加密算法结束*/ - - fclose(FilePointerSource); - fclose(FilePointerTarget); - - return 1; - } - - int RunDecryptFile(char *D_SourceFileName, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_TargetFileNewName) - { - FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 - char buffer[1024]; //缓冲区,用于存放从文件读取的数据 - - int FileByteData, //每次从文件中读取的字节数 - RTNOC, //循环次数 - KeyLength = strlen(D_KEY), //密钥的长度 - KeyLength2 = strlen(D_KEY2), - KeyLength3 = strlen(D_KEY3); - - FilePointerSource = fopen(D_SourceFileName, "rb"); //以二进制方式读取文件 - if(FilePointerSource== NULL) - { - printf("file[%s]failed to open, please check whether the file path and name are entered correctly! \n", D_SourceFileName); - printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", D_SourceFileName); - getchar(); - return 0; - } - - FilePointerTarget = fopen(D_TargetFileNewName, "wb"); //以二进制方式写入文件 - if(FilePointerTarget== NULL) - { - printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", FilePointerTarget); - printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", FilePointerTarget); - getchar(); - return 0; - } - -/******************************************* -* 解密文件 -* -* D_SourceFileName 要解密的文件名 -* D_KEY 密钥 -* D_TargetFileNewName 解密后要保存的文件名 -* -* @return 解密成功或失败的数字表示 -* -* 0 = 解密失败 -* 1 = 解密成功 -********************************************/ - -/*解密算法开始*/ - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 - { - buffer[RTNOC] ^= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 - { - buffer[RTNOC] ^= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0 ) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节进行异或运算 - { - buffer[RTNOC] ^= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/*解密算法结束*/ - - fclose(FilePointerSource); - fclose(FilePointerTarget); - - return 1; - } \ No newline at end of file diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_EODF_By_TDOM.cpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_EODF_By_TDOM.cpp new file mode 100644 index 0000000..9954e9e --- /dev/null +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/Main_EODF_By_TDOM.cpp @@ -0,0 +1,157 @@ +/**************************************************************************** +Read Me - About This Source Code File + +Chinese涓枃: +璁$畻鏈鸿瑷绫诲瀷: C++ +绋嬪簭鏂囦欢鍚: Twilight-Dream-Of-Magic_File_Lock +绋嬪簭骞冲彴绫诲瀷: Windows 鍛戒护琛屾帶鍒跺彴 +绋嬪簭瀹為檯浣滅敤: 鏂囦欢瀵圭О寮忓姞瀵嗚В瀵 +鐗堟湰: Beta 1.0 +婧愪唬鐮佷慨鏀规椂闂: 2019-5-31 +浣滆: Twilight-Dream-Of-Magic + +English鑻辨枃: +Computer Language Type: C++ +Program File Name: Twilight-Dream-Of-Magic_File_Lock +Program Platform Type: Windows Command Line Console +The actual role of the program: file symmetric encryption and decryption +Version: Beta 1.0 +Source code modified by: 2019-5-31 +Author: Twilight-Dream-Of-Magic +*****************************************************************************/ + +#include +#include //鏍囧噯杈撳叆杈撳嚭鍑芥暟 +#include //鏍囧噯搴撳嚱鏁 +#include //瀛楃涓插鐞嗗嚱鏁 +#include + +using namespace std; + +//typedef unsigned char byte; + +int RunEncryptFile(char *E_SourceFileName, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_TargetFileNewName); +int RunDecryptFile(char *D_SourceFileName, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_TargetFileNewName); + +int main() +{ + string Load_User_Keyboard_Input; + + std :: cout << "----------" << endl; + std :: cout << "Enter 1 EncryptFile" << endl; + std :: cout << "Enter 2 DecryptFile" << endl; + std :: cout << "Enter 3 Exit Program" << endl; + std :: cout << "----------" << endl; + std :: cout << "" << endl; + std :: cout << "System:Input And Output/Enter>"; + + std :: cin >> Load_User_Keyboard_Input; + getchar(); + + if(Load_User_Keyboard_Input == "1") + { + char E_SourceFileName[4096], // 鍔犲瘑鐨勬枃浠跺悕 + E_TargetFileNewName[4096]; // 鍔犲瘑鍚庤淇濆瓨鐨勬枃浠跺悕 + + char E_KEY[128], //File (Encryption or Encrypted) key 鏂囦欢鍔犲瘑瀵嗛挜 + E_KEY2[128], + E_KEY3[128]; + + printf("Please input >>> the source file name\n(Contains the directory name):\n"); + printf("杈撳叆瑕佸姞瀵嗙殑鏂囦欢鍚,[C:\]涓嶈杈撳叆绌烘牸(鍚矾寰)锛歕n"); + scanf("%s", E_SourceFileName); + + printf("\n"); + printf("杈撳叆(闀垮害灏忎簬128)瀵嗛挜,涓嶈杈撳叆绌烘牸锛歕n"); //瀵嗛挜鏄敤鎴疯嚜宸卞畾涔夌殑锛(闀垮害灏忎簬128)銆傚彲浠ラ殢鎰忕粰闇瑕佸姞瀵嗙殑鏂囦欢娣诲姞瀵嗛挜 + printf("Please input >>> the key,Do not enter spaces!\n(length less than 128):\n"); + scanf("%s", E_KEY); + + printf("\n"); + printf("杈撳叆(闀垮害灏忎簬128)瀵嗛挜2,涓嶈杈撳叆绌烘牸锛歕n"); //瀵嗛挜鏄敤鎴疯嚜宸卞畾涔夌殑锛(闀垮害灏忎簬128)銆傚彲浠ラ殢鎰忕粰闇瑕佸姞瀵嗙殑鏂囦欢娣诲姞瀵嗛挜 + printf("Please input >>> the key2,Do not enter spaces!\n(length less than 128):\n"); + scanf("%s", E_KEY2); + + printf("\n"); + printf("杈撳叆(闀垮害灏忎簬128)瀵嗛挜3,涓嶈杈撳叆绌烘牸锛歕n"); //瀵嗛挜鏄敤鎴疯嚜宸卞畾涔夌殑锛(闀垮害灏忎簬128)銆傚彲浠ラ殢鎰忕粰闇瑕佸姞瀵嗙殑鏂囦欢娣诲姞瀵嗛挜 + printf("Please input >>> the key3,Do not enter spaces!\n(length less than 128):\n"); + scanf("%s", E_KEY3); + + printf("\n"); + printf("Please input >>> the target file new name(Contains the directory name):\n"); + printf("鍔犲瘑鍚庣殑鏂囦欢鍚,涓嶈杈撳叆绌烘牸(鍚矾寰)锛歕n"); //缁欏姞瀵嗗悗鐨勬枃浠跺懡鍚嶏紝骞朵繚瀛 + scanf("%s",E_TargetFileNewName); + + printf("Please wait, read and write in the file......\n"); + printf("璇风瓑寰咃紝鏂囦欢璇诲啓涓......\n"); + getchar(); + + if(RunEncryptFile(E_SourceFileName, E_KEY, E_KEY2, E_KEY3, E_TargetFileNewName) == 1) + { + printf("鎭枩浣狅紝鏂囦欢[%s]鍔犲瘑鎴愬姛锛屼繚瀛樺湪[%s]銆俓n", E_SourceFileName, E_TargetFileNewName); + printf("Congratulations, the file [%s] is encrypted successfully, saved in [%s]. \n", E_SourceFileName, E_TargetFileNewName); + getchar(); + system("pause"); + return 0; + } + } + if(Load_User_Keyboard_Input == "2") + { + char D_SourceFileName[4096]; //婧愭枃浠跺悕 + char D_TargetFileNewName[4096]; //鐩爣鏂囦欢鏂板悕绉 + + char D_KEY[128], //File (Decryption or Decrypted) key 鏂囦欢瑙e瘑瀵嗛挜 + D_KEY2[128], + D_KEY3[128]; + + printf("\n"); + printf("Please input >>> the source file name\n(Contains the directory name):\n"); + printf("杈撳叆瑕佽В瀵嗙殑鏂囦欢鍚,[C:\]涓嶈杈撳叆绌烘牸(鍚矾寰)锛歕n"); + scanf("%s", D_SourceFileName); + + printf("\n"); + printf("杈撳叆(闀垮害灏忎簬128)瀵嗛挜,涓嶈杈撳叆绌烘牸锛歕n"); //瀵嗛挜鏄敤鎴疯嚜宸卞畾涔夌殑锛屽彲浠ラ殢鎰忕粰闇瑕佽В瀵嗙殑鏂囦欢杈撳叆瀵嗛挜 + printf("Please input >>> the key,Do not enter spaces!\n(length less than 128):\n"); + scanf("%s", D_KEY); + + printf("\n"); + printf("杈撳叆(闀垮害灏忎簬128)瀵嗛挜2,涓嶈杈撳叆绌烘牸锛歕n"); + printf("Please input >>> the key2,Do not enter spaces!\n(length less than 128):\n"); + scanf("%s", D_KEY2); + + printf("\n"); + printf("杈撳叆(闀垮害灏忎簬128)瀵嗛挜3,涓嶈杈撳叆绌烘牸锛歕n"); + printf("Please input >>> the key3,Do not enter spaces!\n(length less than 128):\n"); + scanf("%s", D_KEY3); + + printf("\n"); + printf("Please input >>> the target file new name(Contains the directory name):\n"); + printf("瑙e瘑鍚庣殑鏂囦欢鍚,涓嶈杈撳叆绌烘牸(鍚矾寰)锛歕n"); //缁欒В瀵嗗悗鐨勬枃浠跺懡鍚嶏紝骞朵繚瀛 + scanf("%s",D_TargetFileNewName); + + printf("Please wait, read and write in the file......\n"); + printf("璇风瓑寰咃紝鏂囦欢璇诲啓涓......\n"); + getchar(); + + if(RunDecryptFile(D_SourceFileName, D_KEY, D_KEY2, D_KEY3, D_TargetFileNewName) == 1) + { + printf("鎭枩浣狅紝鏂囦欢[%s]瑙e瘑鎴愬姛锛屼繚瀛樺湪[%s]銆俓n", D_SourceFileName, D_TargetFileNewName); + printf("Congratulations, the file [%s] is decrypted successfully, saved in [%s]. \n", D_SourceFileName, D_TargetFileNewName); + getchar(); + system("pause"); + return 0; + } + } + + if(Load_User_Keyboard_Input == "3") + { + return 0; + } + else + { + std :: cout << "User Entered Is Invalid !" << endl; + getchar(); + exit(1); + } +} + +#include "EDOF_By_TDOM.hpp" \ No newline at end of file diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/StdAfx.h b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/StdAfx.h index e87646a..00d7f10 100644 --- a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/StdAfx.h +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version/StdAfx.h @@ -16,7 +16,7 @@ #define DLLEXPORT __declspec(dllexport) #define DLLIMPORT __declspec(dllimport) -#include "stdio.h" +//#include #include #include #include diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/EODF2_By_TDOM.hpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/EODF2_By_TDOM.hpp new file mode 100644 index 0000000..4d02369 --- /dev/null +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/EODF2_By_TDOM.hpp @@ -0,0 +1,621 @@ +/******************************************* + * 加密文件 + * + * E_SourceFileName 要加密的文件名 + * E_KEY 密钥 + * E_TargetFileNewName 加密后要保存的文件名 + * + * @return 加密成功或失败的数字表示 + * + * 0 = 加密失败 + * 1 = 加密成功 + ********************************************/ + + int RunEncryptFile(char *E_SourceFileName, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_TargetFileNewName) + { + FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 + char buffer[1024]; //缓冲区,用于存放从文件读取的数据 + + int FileByteData, //每次需要从文件容器中,处理的(数据项目)内容的字节数量 + RTNOC, //运行循环次数 (Run The Number Of Cycles) + KeyLength = strlen(E_KEY), //密钥的长度 + KeyLength2 = strlen(E_KEY2), + KeyLength3 = strlen(E_KEY3); + + FilePointerSource = fopen(E_SourceFileName, "rb"); //以二进制方式读取文件 + if(FilePointerSource == NULL) + { + printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", E_SourceFileName); + printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", E_SourceFileName); + getchar(); + return 0; + } + + FilePointerTarget = fopen(E_TargetFileNewName, "wb"); //以二进制方式写入文件 + if(FilePointerTarget == NULL) + { + printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", E_TargetFileNewName); + printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", E_TargetFileNewName); + getchar(); + return 0; + } + +/*加密算法开始*/ +//依次运行三个大型加密模块 +//Run three large encryption modules in turn + +//文件和密钥在缓冲区中计算 +//The file and key are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 + { + buffer[RTNOC] *= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥2在缓冲区中计算 +//The file and key2 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行异或运算 + { + buffer[RTNOC] ^= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递增运算 + { + buffer[RTNOC] += E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递乘运算 + { + buffer[RTNOC] *= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥3在缓冲区中计算 +//The file and key3 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行异或运算 + { + buffer[RTNOC] ^= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递增运算 + { + buffer[RTNOC] += E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递乘运算 + { + buffer[RTNOC] *= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +/***********************************************************************************************************************************************************/ + +//文件和密钥在缓冲区中计算 +//The file and key are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 + { + buffer[RTNOC] *= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥2在缓冲区中计算 +//The file and key2 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行异或运算 + { + buffer[RTNOC] ^= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递增运算 + { + buffer[RTNOC] += E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递乘运算 + { + buffer[RTNOC] *= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥3在缓冲区中计算 +//The file and key3 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行异或运算 + { + buffer[RTNOC] ^= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递增运算 + { + buffer[RTNOC] += E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递乘运算 + { + buffer[RTNOC] *= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +/***********************************************************************************************************************************************************/ + +//文件和密钥在缓冲区中计算 +//The file and key are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 + { + buffer[RTNOC] *= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥2在缓冲区中计算 +//The file and key2 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行异或运算 + { + buffer[RTNOC] ^= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递增运算 + { + buffer[RTNOC] += E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递乘运算 + { + buffer[RTNOC] *= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥3在缓冲区中计算 +//The file and key3 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行异或运算 + { + buffer[RTNOC] ^= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递增运算 + { + buffer[RTNOC] += E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递乘运算 + { + buffer[RTNOC] *= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +/*加密算法结束*/ + + fclose(FilePointerSource); + fclose(FilePointerTarget); + + DeleteFile(E_SourceFileName); + + return 1; + } + + int RunDecryptFile(char *D_SourceFileName, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_TargetFileNewName) + { + FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 + char buffer[1024]; //缓冲区,用于存放从文件读取的数据 + + int FileByteData, //每次需要从文件容器中,处理的(数据项目)内容的字节数量 + RTNOC, //运行循环次数 (Run The Number Of Cycles) + KeyLength = strlen(D_KEY), //密钥的长度 + KeyLength2 = strlen(D_KEY2), + KeyLength3 = strlen(D_KEY3); + + FilePointerSource = fopen(D_SourceFileName, "rb"); //以二进制方式读取文件 + if(FilePointerSource == NULL) + { + printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", D_SourceFileName); + printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", D_SourceFileName); + getchar(); + return 0; + } + + FilePointerTarget = fopen(D_TargetFileNewName, "wb"); //以二进制方式写入文件 + if(FilePointerTarget == NULL) + { + printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", D_TargetFileNewName); + printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", D_TargetFileNewName); + getchar(); + return 0; + } + +/******************************************* +* 解密文件 +* +* D_SourceFileName 要解密的文件名 +* D_KEY 密钥 +* D_TargetFileNewName 解密后要保存的文件名 +* +* @return 解密成功或失败的数字表示 +* +* 0 = 解密失败 +* 1 = 解密成功 + ********************************************/ + +/*解密算法开始*/ +//依次运行大型三个解密模块 +//Run three large decryption modules in turn + +//文件和密钥在缓冲区中计算 +//The file and key are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递减运算 + { + buffer[RTNOC] -= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递除运算 + { + buffer[RTNOC] /= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥2在缓冲区中计算 +//The file and key2 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行异或运算 + { + buffer[RTNOC] ^= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递减运算 + { + buffer[RTNOC] -= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递除运算 + { + buffer[RTNOC] /= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥3在缓冲区中计算 +//The file and key3 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行异或运算 + { + buffer[RTNOC] ^= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递减运算 + { + buffer[RTNOC] -= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递除运算 + { + buffer[RTNOC] /= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +/***********************************************************************************************************************************************************/ + +//文件和密钥在缓冲区中计算 +//The file and key are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递减运算 + { + buffer[RTNOC] -= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递除运算 + { + buffer[RTNOC] /= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥2在缓冲区中计算 +//The file and key2 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行异或运算 + { + buffer[RTNOC] ^= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递减运算 + { + buffer[RTNOC] -= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递除运算 + { + buffer[RTNOC] /= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥3在缓冲区中计算 +//The file and key3 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行异或运算 + { + buffer[RTNOC] ^= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递减运算 + { + buffer[RTNOC] -= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递除运算 + { + buffer[RTNOC] /= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +/***********************************************************************************************************************************************************/ + +//文件和密钥在缓冲区中计算 +//The file and key are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递减运算 + { + buffer[RTNOC] -= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递除运算 + { + buffer[RTNOC] /= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥2在缓冲区中计算 +//The file and key2 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行异或运算 + { + buffer[RTNOC] ^= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递减运算 + { + buffer[RTNOC] -= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递除运算 + { + buffer[RTNOC] /= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥3在缓冲区中计算 +//The file and key3 are counted in Buffer + + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行异或运算 + { + buffer[RTNOC] ^= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递减运算 + { + buffer[RTNOC] -= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递除运算 + { + buffer[RTNOC] /= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + +/*解密算法结束*/ + + fclose(FilePointerSource); + fclose(FilePointerTarget); + + return 1; + } \ No newline at end of file diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.cpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.cpp deleted file mode 100644 index 728eca7..0000000 --- a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/**************************************************************************** -Read Me - About This Source Code File - -Chinese中文: -计算机语言类型: C++ -程序文件名: Twlilght_Yujiang_File_Lock -程序平台类型: Windows 命令行控制台 -程序实际作用: 文件对称式加密解密 -版本: Beta 2.0 -源代码修改时间: 2017-8-11 -作者:Twlilght_Yujiang - -English英文: -Chinese -Computer Language Type: C ++ -Program File Name: Twlilght_Yujiang_File_Lock -Program Platform Type: Windows Command Line Console -The actual role of the program: file symmetric encryption and decryption -Version: Beta 2.0 -Source code modified by: 2017-8-11 -Author: Twlilght_Yujiang -*****************************************************************************/ - -#include -#include -#include //C标准输入输出函数 -#include //C标准库函数 -#include //字符串处理函数 -#include - -using namespace std; - -//typedef unsigned char byte; - -int RunEncryptFile(char *E_SourceFileName, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_TargetFileNewName); -int RunDecryptFile(char *D_SourceFileName, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_TargetFileNewName); - -void ConsoleTableColorSet(int R,int G,int B) -{ - if(R<0) R=0; - if(R>1) R=1; - - if(G<0) G=0; - if(G>1) G=1; - - if(B<0) B=0; - if(B>1) B=1; - - if(R == 1 && G == 1 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE); - } - else if(R == 1 && G == 1 && B == 0) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN); - } - else if(R == 1 && G == 0 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE); - } - else if(R == 0 && G == 1 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE); - } - else if(R == 1 && G == 0 && B == 0) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED); - } - else if(R == 0 && G == 1 && B == 0) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN); - } - else if(R == 0 && G == 0 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE); - } - else - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY); - } -} - -int main() -{ -ProgramMainMenu: - - string Load_User_Keyboard_Input; - - system("color 0A"); - - std :: cout << "----------" << endl; - std :: cout << "Enter 1 EncryptFile" << endl; - std :: cout << "Enter 2 DecryptFile" << endl; - std :: cout << "Enter 3 Exit Program" << endl; - std :: cout << "----------" << endl; - std :: cout << "" << endl; - std :: cout << "System:Input And Output/Enter>"; - - std :: cin >> Load_User_Keyboard_Input; - getchar(); - - if(Load_User_Keyboard_Input == "1") - { - system("cls"); - system("color 1A"); - - char E_SourceFileName[4096], // 加密的文件名 - E_TargetFileNewName[4096]; // 加密后要保存的文件名 - - //char E_TargetFileLastNameOutput = (E_TargetFileNewName + ".TY_ENCRYPTED"); //最后保存的加密后文件名 - - char E_KEY[128], //File (Encryption or Encrypted) key 文件加密密钥 - E_KEY2[128], - E_KEY3[128]; - - std :: cout << "Please input >>> the source file name.\nDo not enter spaces!\n(Contains the directory name):" << endl; - std :: cout << "输入要加密的文件名,[C:\]不要输入空格(含路径):" << endl; - std :: cin >> E_SourceFileName; - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥,不要输入空格:" << endl; //密钥是用户自己定义的,(长度小于128)。可以随意给需要加密的文件添加密钥 - std :: cout << "Please input >>> the key,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> E_KEY; - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥2,不要输入空格:" << endl; - std :: cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> E_KEY2; - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥3,不要输入空格:" << endl; - std :: cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> E_KEY3; - - std :: cout << "\n"; - std :: cout << "Please output >>> the target file new name.\nDo not enter spaces!\n(Contains the directory name):" << endl; - std :: cout << "加密后的文件名,不要输入空格(含路径):" << endl; //给加密后的文件命名,并保存 - std :: cin >> E_TargetFileNewName; - system("cls"); - - std :: cout << "正在记录并导出,本次用于文件加密,3个密钥字符串......" << endl; - std :: cout << "Is being recorded and exported, this time for file encryption, 3 key string......" << endl; - ofstream PasswordOutputKeyFile; - PasswordOutputKeyFile.open("FILE-ENCRYPTION-DECRYPTIPN-PASSWORD.KEY.TXT"); - PasswordOutputKeyFile << "Twlilght_Yujiang File Lock Password [Key String] Save\n" << endl; - PasswordOutputKeyFile << "\n" << endl; - PasswordOutputKeyFile << "Source Input File Name and Path: " << E_SourceFileName << "\n" << endl; - PasswordOutputKeyFile << "EncryptFile: New Output Target File Name and Path: " << E_TargetFileNewName << "\n" << endl; - PasswordOutputKeyFile << "Key string1 [Password1]: " << E_KEY << "\n" << endl; - PasswordOutputKeyFile << "Key string2 [Password2]: " << E_KEY2 << "\n" << endl; - PasswordOutputKeyFile << "Key string3 [Password3]: " << E_KEY3 << "\n" << endl; - PasswordOutputKeyFile << "<******************************************************************************************>" << "\n" << endl; - PasswordOutputKeyFile.close(); - - std :: cout << "Please wait, read and write in the file......" << endl; - std :: cout << "请等待,文件读写中......" << endl; - getchar(); - - if(RunEncryptFile(E_SourceFileName, E_KEY, E_KEY2, E_KEY3, E_TargetFileNewName)) - { - printf("恭喜你,文件[%s]加密成功,保存在[%s]。\n", E_SourceFileName, E_TargetFileNewName); - printf("Congratulations, the file [%s] is encrypted successfully, saved in [%s]. \n", E_SourceFileName, E_TargetFileNewName); - getchar(); - system("pause"); - system("cls"); - goto ProgramMainMenu; - } - } - if(Load_User_Keyboard_Input == "2") - { - system("cls"); - system("color 1A"); - - char D_SourceFileName[4096], //源文件名 - D_TargetFileNewName[4096]; //目标文件新名称 - - //char D_TargetFileLastNameOutput = (D_TargetFileNewName - ".TY_ENCRYPTED"); //最后保存的解密后文件名 - - char D_KEY[128], //File (Decryption or Decrypted) key 文件解密密钥 - D_KEY2[128], - D_KEY3[128]; - - std :: cout << "Please input >>> the source file name.\nDo not enter spaces!\n(Contains the directory name):" << endl; - std :: cout << "输入要解密的文件名,[C:\]不要输入空格(含路径):" << endl; - std :: cin >> D_SourceFileName; - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥,不要输入空格:" << endl; //密钥是用户自己定义的,可以随意给需要解密的文件输入密钥 - std :: cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> D_KEY; - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥2,不要输入空格:" << endl; - std :: cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> D_KEY2; - - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥3,不要输入空格:" << endl; - std :: cout << "Please input >>> the key,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> D_KEY3; - - std :: cout << "\n"; - std :: cout << "Please output >>> the target file new name.\nDo not enter spaces!\n(Contains the directory name):" << endl; - std :: cout << "解密后的文件名,不要输入空格(含路径):" << endl; //给解密后的文件命名,并保存 - std :: cin >> D_TargetFileNewName; - system("cls"); - - std :: cout << "Please wait, read and write in the file......" << endl; - std :: cout << "请等待,文件读写中......" << endl; - getchar(); - - if(RunDecryptFile(D_SourceFileName, D_KEY, D_KEY2, D_KEY3, D_TargetFileNewName)) - { - printf("恭喜你,文件[%s]解密成功,保存在[%s]。\n", D_SourceFileName, D_TargetFileNewName); - printf("Congratulations, the file [%s] is decrypted successfully, saved in [%s]. \n", D_SourceFileName, D_TargetFileNewName); - getchar(); - system("pause"); - system("cls"); - goto ProgramMainMenu; - } - } - - if(Load_User_Keyboard_Input == "3") - { - return 0; - } - else - { - std :: cout << "User Input Error !" << endl; - getchar(); - exit(1); - } -} - -#include "Main_2_By_Twlilght_Yujiang.hpp" \ No newline at end of file diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.hpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.hpp deleted file mode 100644 index 70c653c..0000000 --- a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_2_By_Twlilght_Yujiang.hpp +++ /dev/null @@ -1,621 +0,0 @@ -/******************************************* - * 加密文件 - * - * E_SourceFileName 要加密的文件名 - * E_KEY 密钥 - * E_TargetFileNewName 加密后要保存的文件名 - * - * @return 加密成功或失败的数字表示 - * - * 0 = 加密失败 - * 1 = 加密成功 - ********************************************/ - - int RunEncryptFile(char *E_SourceFileName, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_TargetFileNewName) - { - FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 - char buffer[1024]; //缓冲区,用于存放从文件读取的数据 - - int FileByteData, //每次从文件中读取的字节数 - RTNOC, //运行循环次数 (Run The Number Of Cycles) - KeyLength = strlen(E_KEY), //密钥的长度 - KeyLength2 = strlen(E_KEY2), - KeyLength3 = strlen(E_KEY3); - - FilePointerSource = fopen(E_SourceFileName, "rb"); //以二进制方式读取文件 - if(FilePointerSource == NULL) - { - printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", E_SourceFileName); - printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", E_SourceFileName); - getchar(); - return 0; - } - - FilePointerTarget = fopen(E_TargetFileNewName, "wb"); //以二进制方式写入文件 - if(FilePointerTarget == NULL) - { - printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", E_TargetFileNewName); - printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", E_TargetFileNewName); - getchar(); - return 0; - } - -/*加密算法开始*/ -//依次运行三个大型加密模块 -//Run three large encryption modules in turn - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行异或运算 - { - buffer[RTNOC] ^= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递增运算 - { - buffer[RTNOC] += E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递乘运算 - { - buffer[RTNOC] *= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行异或运算 - { - buffer[RTNOC] ^= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递增运算 - { - buffer[RTNOC] += E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递乘运算 - { - buffer[RTNOC] *= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/***********************************************************************************************************************************************************/ - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行异或运算 - { - buffer[RTNOC] ^= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递增运算 - { - buffer[RTNOC] += E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递乘运算 - { - buffer[RTNOC] *= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行异或运算 - { - buffer[RTNOC] ^= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递增运算 - { - buffer[RTNOC] += E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递乘运算 - { - buffer[RTNOC] *= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/***********************************************************************************************************************************************************/ - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行异或运算 - { - buffer[RTNOC] ^= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递增运算 - { - buffer[RTNOC] += E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY2进行递乘运算 - { - buffer[RTNOC] *= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行异或运算 - { - buffer[RTNOC] ^= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递增运算 - { - buffer[RTNOC] += E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY3进行递乘运算 - { - buffer[RTNOC] *= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/*加密算法结束*/ - - fclose(FilePointerSource); - fclose(FilePointerTarget); - - DeleteFile(E_SourceFileName); - - return 1; - } - - int RunDecryptFile(char *D_SourceFileName, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_TargetFileNewName) - { - FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 - char buffer[1024]; //缓冲区,用于存放从文件读取的数据 - - int FileByteData, //每次从文件中读取的字节数 - RTNOC, //运行循环次数 (Run The Number Of Cycles) - KeyLength = strlen(D_KEY), //密钥的长度 - KeyLength2 = strlen(D_KEY2), - KeyLength3 = strlen(D_KEY3); - - FilePointerSource = fopen(D_SourceFileName, "rb"); //以二进制方式读取文件 - if(FilePointerSource == NULL) - { - printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", D_SourceFileName); - printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", D_SourceFileName); - getchar(); - return 0; - } - - FilePointerTarget = fopen(D_TargetFileNewName, "wb"); //以二进制方式写入文件 - if(FilePointerTarget == NULL) - { - printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", D_TargetFileNewName); - printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", D_TargetFileNewName); - getchar(); - return 0; - } - -/******************************************* -* 解密文件 -* -* D_SourceFileName 要解密的文件名 -* D_KEY 密钥 -* D_TargetFileNewName 解密后要保存的文件名 -* -* @return 解密成功或失败的数字表示 -* -* 0 = 解密失败 -* 1 = 解密成功 - ********************************************/ - -/*解密算法开始*/ -//依次运行大型三个解密模块 -//Run three large decryption modules in turn - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行异或运算 - { - buffer[RTNOC] ^= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递减运算 - { - buffer[RTNOC] -= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递除运算 - { - buffer[RTNOC] /= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行异或运算 - { - buffer[RTNOC] ^= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递减运算 - { - buffer[RTNOC] -= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递除运算 - { - buffer[RTNOC] /= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行异或运算 - { - buffer[RTNOC] ^= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递减运算 - { - buffer[RTNOC] -= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递除运算 - { - buffer[RTNOC] /= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/***********************************************************************************************************************************************************/ - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行异或运算 - { - buffer[RTNOC] ^= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递减运算 - { - buffer[RTNOC] -= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递除运算 - { - buffer[RTNOC] /= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行异或运算 - { - buffer[RTNOC] ^= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递减运算 - { - buffer[RTNOC] -= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递除运算 - { - buffer[RTNOC] /= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行异或运算 - { - buffer[RTNOC] ^= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递减运算 - { - buffer[RTNOC] -= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递除运算 - { - buffer[RTNOC] /= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/***********************************************************************************************************************************************************/ - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行异或运算 - { - buffer[RTNOC] ^= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递减运算 - { - buffer[RTNOC] -= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY进行递除运算 - { - buffer[RTNOC] /= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行异或运算 - { - buffer[RTNOC] ^= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递减运算 - { - buffer[RTNOC] -= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY2进行递除运算 - { - buffer[RTNOC] /= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行异或运算 - { - buffer[RTNOC] ^= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递减运算 - { - buffer[RTNOC] -= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和D_KEY3进行递除运算 - { - buffer[RTNOC] /= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -/*解密算法结束*/ - - fclose(FilePointerSource); - fclose(FilePointerTarget); - - return 1; - } \ No newline at end of file diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_EODF2_By_TDOM.cpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_EODF2_By_TDOM.cpp new file mode 100644 index 0000000..396b0eb --- /dev/null +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/Main_EODF2_By_TDOM.cpp @@ -0,0 +1,234 @@ +/**************************************************************************** +Read Me - About This Source Code File + +Chinese涓枃: +璁$畻鏈鸿瑷绫诲瀷: C++ +绋嬪簭鏂囦欢鍚: Twilight-Dream-Of-Magic File_Lock +绋嬪簭骞冲彴绫诲瀷: Windows 鍛戒护琛屾帶鍒跺彴 +绋嬪簭瀹為檯浣滅敤: 鏂囦欢瀵圭О寮忓姞瀵嗚В瀵 +鐗堟湰: Beta 2.0 +婧愪唬鐮佷慨鏀规椂闂: 2019-5-31 +浣滆: Twilight-Dream-Of-Magic + +English鑻辨枃: +Computer Language Type: C ++ +Program File Name: Twilight-Dream-Of-Magic File_Lock +Program Platform Type: Windows Command Line Console +The actual role of the program: file symmetric encryption and decryption +Version: Beta 2.0 +Source code modified by: 2019-5-31 +Author: Twilight-Dream-Of-Magic +*****************************************************************************/ + +#include +#include +#include //C鏍囧噯杈撳叆杈撳嚭鍑芥暟 +#include //C鏍囧噯搴撳嚱鏁 +#include //瀛楃涓插鐞嗗嚱鏁 +#include + +using namespace std; + +//typedef unsigned char byte; + +int RunEncryptFile(char *E_SourceFileName, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_TargetFileNewName); +int RunDecryptFile(char *D_SourceFileName, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_TargetFileNewName); + +void ConsoleTableColorSet(int R,int G,int B) +{ + if(R<0) R=0; + if(R>1) R=1; + + if(G<0) G=0; + if(G>1) G=1; + + if(B<0) B=0; + if(B>1) B=1; + + if(R == 1 && G == 1 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE); + } + else if(R == 1 && G == 1 && B == 0) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN); + } + else if(R == 1 && G == 0 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE); + } + else if(R == 0 && G == 1 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE); + } + else if(R == 1 && G == 0 && B == 0) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED); + } + else if(R == 0 && G == 1 && B == 0) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN); + } + else if(R == 0 && G == 0 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE); + } + else + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY); + } +} + +int main() +{ +ProgramMainMenu: + + string Load_User_Keyboard_Input; + + system("color 0A"); + + std :: cout << "----------" << endl; + std :: cout << "Enter 1 EncryptFile" << endl; + std :: cout << "Enter 2 DecryptFile" << endl; + std :: cout << "Enter 3 Exit Program" << endl; + std :: cout << "----------" << endl; + std :: cout << "" << endl; + std :: cout << "System:Input And Output/Enter>"; + + std :: cin >> Load_User_Keyboard_Input; + cin.get(); + + if(Load_User_Keyboard_Input == "1") + { + system("cls"); + system("color 1A"); + + char E_SourceFileName[4096], // 鍔犲瘑鐨勬枃浠跺悕 + E_TargetFileNewName[4096]; // 鍔犲瘑鍚庤淇濆瓨鐨勬枃浠跺悕 + + //char E_TargetFileLastNameOutput = (E_TargetFileNewName + ".TY_ENCRYPTED"); //鏈鍚庝繚瀛樼殑鍔犲瘑鍚庢枃浠跺悕 + + char E_KEY[128], //File (Encryption or Encrypted) key 鏂囦欢鍔犲瘑瀵嗛挜 + E_KEY2[128], + E_KEY3[128]; + + std :: cout << "Please input >>> the source file name.\nDo not enter spaces!\n(Contains the directory name):" << endl; + std :: cout << "杈撳叆瑕佸姞瀵嗙殑鏂囦欢鍚,[C:\]涓嶈杈撳叆绌烘牸(鍚矾寰)锛" << endl; + std :: cin >> E_SourceFileName; + + std :: cout << "\n"; + std :: cout << "杈撳叆(闀垮害灏忎簬128)瀵嗛挜,涓嶈杈撳叆绌烘牸锛" << endl; //瀵嗛挜鏄敤鎴疯嚜宸卞畾涔夌殑锛(闀垮害灏忎簬128)銆傚彲浠ラ殢鎰忕粰闇瑕佸姞瀵嗙殑鏂囦欢娣诲姞瀵嗛挜 + std :: cout << "Please input >>> the key,Do not enter spaces!\n(length less than 128):" << endl; + cin.getline(E_KEY, 128, '\n').get(); + + std :: cout << "\n"; + std :: cout << "杈撳叆(闀垮害灏忎簬128)瀵嗛挜2,涓嶈杈撳叆绌烘牸锛" << endl; + std :: cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 128):" << endl; + cin.getline(E_KEY2, 128, '\n').get(); + + std :: cout << "\n"; + std :: cout << "杈撳叆(闀垮害灏忎簬128)瀵嗛挜3,涓嶈杈撳叆绌烘牸锛" << endl; + std :: cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 128):" << endl; + cin.getline(E_KEY3, 128, '\n').get(); + + std :: cout << "\n"; + std :: cout << "Please output >>> the target file new name.\nDo not enter spaces!\n(Contains the directory name):" << endl; + std :: cout << "鍔犲瘑鍚庣殑鏂囦欢鍚,涓嶈杈撳叆绌烘牸(鍚矾寰)锛" << endl; //缁欏姞瀵嗗悗鐨勬枃浠跺懡鍚嶏紝骞朵繚瀛 + std :: cin >> E_TargetFileNewName; + system("cls"); + + std :: cout << "姝e湪璁板綍骞跺鍑猴紝鏈鐢ㄤ簬鏂囦欢鍔犲瘑锛3涓瘑閽ュ瓧绗︿覆......" << endl; + std :: cout << "Is being recorded and exported, this time for file encryption, 3 key string......" << endl; + ofstream PasswordOutputKeyFile; + PasswordOutputKeyFile.open("FILE-ENCRYPTION-DECRYPTION-PASSWORD.KEY.TXT"); + PasswordOutputKeyFile << "Twilight-Dream-Of-Magic File Lock Password [Key String] Save\n" << endl; + PasswordOutputKeyFile << "\n" << endl; + PasswordOutputKeyFile << "Source Input File Name and Path: " << E_SourceFileName << "\n" << endl; + PasswordOutputKeyFile << "EncryptFile: New Output Target File Name and Path: " << E_TargetFileNewName << "\n" << endl; + PasswordOutputKeyFile << "Key string1 [Password1]: " << E_KEY << "\n" << endl; + PasswordOutputKeyFile << "Key string2 [Password2]: " << E_KEY2 << "\n" << endl; + PasswordOutputKeyFile << "Key string3 [Password3]: " << E_KEY3 << "\n" << endl; + PasswordOutputKeyFile << "<******************************************************************************************>" << "\n" << endl; + PasswordOutputKeyFile.close(); + + std :: cout << "Please wait, read and write in the file......" << endl; + std :: cout << "璇风瓑寰咃紝鏂囦欢璇诲啓涓......" << endl; + cin.get(); + + if(RunEncryptFile(E_SourceFileName, E_KEY, E_KEY2, E_KEY3, E_TargetFileNewName) == 1) + { + printf("鎭枩浣狅紝鏂囦欢[%s]鍔犲瘑鎴愬姛锛屼繚瀛樺湪[%s]銆俓n", E_SourceFileName, E_TargetFileNewName); + printf("Congratulations, the file [%s] is encrypted successfully, saved in [%s]. \n", E_SourceFileName, E_TargetFileNewName); + cin.get(); + system("pause"); + system("cls"); + goto ProgramMainMenu; + } + } + if(Load_User_Keyboard_Input == "2") + { + system("cls"); + system("color 1A"); + + char D_SourceFileName[4096], //婧愭枃浠跺悕 + D_TargetFileNewName[4096]; //鐩爣鏂囦欢鏂板悕绉 + + //char D_TargetFileLastNameOutput = (D_TargetFileNewName - ".TY_DECRYPTED"); //鏈鍚庝繚瀛樼殑瑙e瘑鍚庢枃浠跺悕 + + char D_KEY[128], //File (Decryption or Decrypted) key 鏂囦欢瑙e瘑瀵嗛挜 + D_KEY2[128], + D_KEY3[128]; + + std :: cout << "Please input >>> the source file name.\nDo not enter spaces!\n(Contains the directory name):" << endl; + std :: cout << "杈撳叆瑕佽В瀵嗙殑鏂囦欢鍚,[C:\]涓嶈杈撳叆绌烘牸(鍚矾寰)锛" << endl; + std :: cin >> D_SourceFileName; + + std :: cout << "\n"; + std :: cout << "杈撳叆(闀垮害灏忎簬128)瀵嗛挜,涓嶈杈撳叆绌烘牸锛" << endl; //瀵嗛挜鏄敤鎴疯嚜宸卞畾涔夌殑锛屽彲浠ラ殢鎰忕粰闇瑕佽В瀵嗙殑鏂囦欢杈撳叆瀵嗛挜 + std :: cout << "Please input >>> the key,Do not enter spaces!\n(length less than 128):" << endl; + cin.getline(D_KEY, 128, '\n').get(); + + std :: cout << "\n"; + std :: cout << "杈撳叆(闀垮害灏忎簬128)瀵嗛挜2,涓嶈杈撳叆绌烘牸锛" << endl; + std :: cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 128):" << endl; + cin.getline(D_KEY2, 128, '\n').get(); + + std :: cout << "\n"; + std :: cout << "杈撳叆(闀垮害灏忎簬128)瀵嗛挜3,涓嶈杈撳叆绌烘牸锛" << endl; + std :: cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 128):" << endl; + cin.getline(D_KEY3, 128, '\n').get(); + + std :: cout << "\n"; + std :: cout << "Please output >>> the target file new name.\nDo not enter spaces!\n(Contains the directory name):" << endl; + std :: cout << "瑙e瘑鍚庣殑鏂囦欢鍚,涓嶈杈撳叆绌烘牸(鍚矾寰)锛" << endl; //缁欒В瀵嗗悗鐨勬枃浠跺懡鍚嶏紝骞朵繚瀛 + std :: cin >> D_TargetFileNewName; + system("cls"); + + std :: cout << "Please wait, read and write in the file......" << endl; + std :: cout << "璇风瓑寰咃紝鏂囦欢璇诲啓涓......" << endl; + cin.get(); + + if(RunDecryptFile(D_SourceFileName, D_KEY, D_KEY2, D_KEY3, D_TargetFileNewName) == 1) + { + printf("鎭枩浣狅紝鏂囦欢[%s]瑙e瘑鎴愬姛锛屼繚瀛樺湪[%s]銆俓n", D_SourceFileName, D_TargetFileNewName); + printf("Congratulations, the file [%s] is decrypted successfully, saved in [%s]. \n", D_SourceFileName, D_TargetFileNewName); + cin.get(); + system("pause"); + system("cls"); + goto ProgramMainMenu; + } + } + + if(Load_User_Keyboard_Input == "3") + { + return 0; + } + else + { + std :: cout << "User Enter Is Invalid !" << endl; + cin.get(); + exit(1); + } +} + +#include "EODF2_By_TDOM.hpp" \ No newline at end of file diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/StdAfx.h b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/StdAfx.h index e87646a..00d7f10 100644 --- a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/StdAfx.h +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version2/StdAfx.h @@ -16,7 +16,7 @@ #define DLLEXPORT __declspec(dllexport) #define DLLIMPORT __declspec(dllimport) -#include "stdio.h" +//#include #include #include #include diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/EODF3_By_TDOM.hpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/EODF3_By_TDOM.hpp new file mode 100644 index 0000000..2780f45 --- /dev/null +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/EODF3_By_TDOM.hpp @@ -0,0 +1,498 @@ +#include //计算机C++语言,标准输入输出函数 Computer C++ language standard input and output functions +#include //计算机C++语言,标准文件流输入输出函数 Computer C++ language standard input and output functions of file stream +#include //计算机C语言,标准文件流输入输出函数 Computer C language standard input and output functions of file stream +#include //计算机C语言标准输入输出函数 Computer C language standard input and output functions +#include //计算机C语言标准库函数 Computer C language standard library functions +#include //计算机C语言字符串处理函数 Computer C language string handling functions +#include //Windows API main function libary + +/******************************************* +* 加密文件 +* +* E_SourceFileName 需要加密的文件名 +* E_KEY 密钥 +* E_TargetFileNewName 加密完成后要保存的文件名 +* +* @return 加密成功或失败的数字表示 +* +* 0 = 加密失败 +* 1 = 加密成功 +********************************************/ + + int RunEncryptFile(const char *E_SourceFileCharPath, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_KEY4, const char *E_TargetFileCharPath) + { + FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 + char buffer[102400]; //缓冲区,用于存放从文件读取的数据 + + unsigned int FileByteDataSize, //每次需要从文件容器中,处理的(数据项目)内容的字节数量 + RTNOC, //运行循环次数 (Run The Number Of Cycles) + KeyLength = strlen(E_KEY), //密钥的长度 + KeyLength2 = strlen(E_KEY2), + KeyLength3 = strlen(E_KEY3), + KeyLength4 = strlen(E_KEY4); + + FilePointerSource = fopen(E_SourceFileCharPath, "rb"); //以二进制方式读取文件 + if(FilePointerSource == NULL) + { + printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", E_SourceFileCharPath); + printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", E_SourceFileCharPath); + getchar(); + return 0; + } + + FilePointerTarget = fopen(E_TargetFileCharPath, "wb+"); //以二进制方式写入文件 + if(FilePointerTarget == NULL) + { + printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", E_TargetFileCharPath); + printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", E_TargetFileCharPath); + getchar(); + return 0; + } + +/*加密算法开始*/ + +/*****************************************************************************buffer[RTNOC]******************************************************************************/ + +//运行大型加密模块 +//Run large encryption module + +//文件和密钥在缓冲区中计算 +//The file and key are counted in Buffer + + int NOIEM; //初始加密模块次数 (Number of initial encryption modules) + int MAX_NOT_E_MODULE = 65; //运行加密模块循环次数 (The maximum number of times the encryption module is running) + + for(NOIEM = 0;NOIEM < MAX_NOT_E_MODULE;NOIEM++) + { + while((FileByteDataSize = fread(buffer, 512, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += E_KEY[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 + { + buffer[RTNOC] *= E_KEY[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 + { + buffer[RTNOC] /= E_KEY[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= E_KEY[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥2在缓冲区中计算 +//The file and key2 are counted in Buffer + + while((FileByteDataSize = fread(buffer, 512, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += E_KEY2[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 + { + buffer[RTNOC] *= E_KEY2[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY2[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 + { + buffer[RTNOC] /= E_KEY2[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= E_KEY2[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥3在缓冲区中计算 +//The file and key3 are counted in Buffer + + while((FileByteDataSize = fread(buffer, 512, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += E_KEY3[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 + { + buffer[RTNOC] *= E_KEY3[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY3[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 + { + buffer[RTNOC] /= E_KEY3[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= E_KEY3[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥4在缓冲区中计算 +//The file and key4 are counted in Buffer + + while((FileByteDataSize = fread(buffer, 512, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += E_KEY4[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 + { + buffer[RTNOC] *= E_KEY4[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY4[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 + { + buffer[RTNOC] /= E_KEY4[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= E_KEY4[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + } + +/***********************************************************************************************************************************************************/ + +/*加密算法结束*/ + + buffer[102400] = {"/x00"}; //Clear File Buffer Space Data + fclose(FilePointerSource); + fclose(FilePointerTarget); + + DeleteFile(E_SourceFileCharPath); + + return 1; + } + + int RunDecryptFile(const char *D_SourceFileCharPath, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_KEY4, const char *D_TargetFileCharPath) + { + FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 + char buffer[102400]; //缓冲区,用于存放从文件读取的数据 + + unsigned int FileByteDataSize, //每次需要从文件容器中,处理的(数据项目)内容的字节数量 + RTNOC, //循环次数 + KeyLength = strlen(D_KEY), //密钥的长度 + KeyLength2 = strlen(D_KEY2), + KeyLength3 = strlen(D_KEY3), + KeyLength4 = strlen(D_KEY4); + + FilePointerSource = fopen(D_SourceFileCharPath, "rb"); //以二进制方式读取文件 + if(FilePointerSource == NULL) + { + printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", D_SourceFileCharPath); + printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", D_SourceFileCharPath); + getchar(); + return 0; + } + + FilePointerTarget = fopen(D_TargetFileCharPath, "wb+"); //以二进制方式写入文件 + if(FilePointerTarget == NULL) + { + printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", D_TargetFileCharPath); + printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", D_TargetFileCharPath); + getchar(); + return 0; + } + +/******************************************* +* 解密文件 +* +* D_SourceFileName 需要解密的文件名 +* D_KEY 密钥 +* D_TargetFileNewName 解密完成后要保存的文件名 +* +* @return 解密成功或失败的数字表示 +* +* 0 = 解密失败 +* 1 = 解密成功 +********************************************/ + +/*解密算法开始*/ + +/***********************************************************************************************************************************************************/ + +//运行大型解密模块 +//Run large decryption module + +//文件和密钥在缓冲区中计算 +//The file and key are counted in Buffer + + int NOIDM; //初始解密模块次数 (Number of initial decryption modules) + int MAX_NOT_D_MODULE = 65; //运行解密模块循环次数 (The maximum number of times the decryption module is running) + + for(NOIDM = 0;NOIDM < MAX_NOT_D_MODULE;NOIDM++) + { + while((FileByteDataSize = fread(buffer, 512, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= D_KEY[RTNOC]; + } + fwrite(buffer, 512, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 + { + buffer[RTNOC] /= D_KEY[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 + { + buffer[RTNOC] *= D_KEY[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += D_KEY[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + + +//文件和密钥2在缓冲区中计算 +//The file and key2 are counted in Buffer + + while((FileByteDataSize = fread(buffer, 512, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= D_KEY2[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 + { + buffer[RTNOC] /= D_KEY2[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY2[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 + { + buffer[RTNOC] *= D_KEY2[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += D_KEY2[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥3在缓冲区中计算 +//The file and key3 are counted in Buffer + + while((FileByteDataSize = fread(buffer, 512, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= D_KEY3[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 + { + buffer[RTNOC] /= D_KEY3[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY3[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 + { + buffer[RTNOC] *= D_KEY3[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += D_KEY3[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + +//文件和密钥4在缓冲区中计算 +//The file and key4 are counted in Buffer + + while((FileByteDataSize = fread(buffer, 512, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= D_KEY4[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 + { + buffer[RTNOC] /= D_KEY4[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY4[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 + { + buffer[RTNOC] *= D_KEY4[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteDataSize = fread(buffer, 512, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteDataSize; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += D_KEY4[RTNOC]; + } + fwrite(buffer, 512, FileByteDataSize, FilePointerTarget); //将buffer中的数据写入文件 + } + } + +/***********************************************************************************************************************************************************/ + +/*解密算法结束*/ + + buffer[102400] = {"/x00"}; //Clear Buffer Space Data + fclose(FilePointerSource); + fclose(FilePointerTarget); + + DeleteFile(D_SourceFileCharPath); + + return 1; + } \ No newline at end of file diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.cpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.cpp deleted file mode 100644 index 1918b9a..0000000 --- a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.cpp +++ /dev/null @@ -1,612 +0,0 @@ -/**************************************************************************** -Read Me - About This Source Code File - -Chinese中文: -计算机语言类型: C++ -程序文件名: Twlilght_Yujiang_File_Lock -程序平台类型: Windows 命令行控制台 -程序实际作用: 文件对称式加密解密 -版本: Beta 3.0 -源代码修改时间: 2017-8-14 -作者:Twlilght_Yujiang - -English英文: -Chinese -Computer Language Type: C ++ -Program File Name: Twlilght_Yujiang_File_Lock -Program Platform Type: Windows Command Line Console -The actual role of the program: file symmetric encryption and decryption -Version: Beta 3.0 -Source code modified by: 2017-8-14 -Author: Twlilght_Yujiang -*****************************************************************************/ - -#include -#include -#include -#include //计算机C语言标准输入输出函数 Computer C language standard input and output functions -#include //计算机C语言标准库函数 Computer C language standard library functions -#include //计算机C语言字符串处理函数 Computer C language string handling functions -#include -#include "stdafx.h" - -//#include //MakeSureDirectoryPathExists(""); -//#pragma comment(lib, "ImageHlp.lib") - -using namespace std; - -//typedef unsigned char byte; - -int RunEncryptFile(const char *E_SourceFileCharPath, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_KEY4, const char *E_TargetFileCharPath); -int RunDecryptFile(const char *D_SourceFileCharPath, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_KEY4, const char *D_TargetFileCharPath); - -string E_IF_PATH = ".\\WorkPath\\Encrypt\\InputFile\\", //加密之前,文件的路径 Before encrypting the path of the file - E_OF_PATH = ".\\WorkPath\\Encrypt\\OutputFile\\"; //加密之后,文件的路径 After encrypting the path of the file - -string E_SourceFileName, // 源文件名 - E_SourceFileMainName, // 源文件主要名 - E_SourceFileExtendedName, // 源文件扩展名 - E_TargetFileExtendedName; // 目标文件扩展名 - -char E_KEY[128], //File (Encryption or Encrypted) key 文件加密密钥 - E_KEY2[128], - E_KEY3[128], - E_KEY4[128]; - -string D_IF_PATH = ".\\WorkPath\\Decrypt\\InputFile\\", //解密之前,文件的路径 Before decrypting the path of the file - D_OF_PATH = ".\\WorkPath\\Decrypt\\OutputFile\\"; //解密之后,文件的路径 After decrypting the path of the file - -string D_SourceFileName, //源文件名 - D_TargetFileMainName, //目标文件主要名 - D_TargetFileTempName, //目标文件临时添加名 - D_TargetFileExtendedName; //目标文件源扩展名 - -char D_KEY[128], //File (Decryption or Decrypted) key 文件解密密钥 - D_KEY2[128], - D_KEY3[128], - D_KEY4[128]; - -void ConsoleTableColorSet(int R,int G,int B) -{ - if(R<0) R=0; - if(R>1) R=1; - - if(G<0) G=0; - if(G>1) G=1; - - if(B<0) B=0; - if(B>1) B=1; - - if(R == 1 && G == 1 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE); - } - else if(R == 1 && G == 1 && B == 0) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN); - } - else if(R == 1 && G == 0 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE); - } - else if(R == 0 && G == 1 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE); - } - else if(R == 1 && G == 0 && B == 0) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED); - } - else if(R == 0 && G == 1 && B == 0) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN); - } - else if(R == 0 && G == 0 && B == 1) - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE); - } - else - { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY); - } -} - -int main() -{ -ProgramMainMenu: - - string Load_User_Keyboard_Input; - - system("color 0A"); - system("cls"); - - std :: cout << "----------------------------------------" << endl; - std :: cout << "Enter 1 Encrypt File" << endl; - std :: cout << "1.加密文件\n" << endl; - std :: cout << "Enter 2 Decrypt File" << endl; - std :: cout << "2.解密文件\n" << endl; - std :: cout << "Enter 3 Use The Information Manual" << endl; - std :: cout << "3.使用信息说明手册\n" << endl; - std :: cout << "Enter 4 Clean Up The Workspace[To Restore The Initial State]" << endl; - std :: cout << "4.清理工作空间[恢复初始状态]\n" << endl; - std :: cout << "Enter 5 Exit Program" << endl; - std :: cout << "5.退出程序\n" << endl; - std :: cout << "----------------------------------------" << endl; - std :: cout << "System:Input And Output/Enter>"; - - std :: cin >> Load_User_Keyboard_Input; - getchar(); - - if(Load_User_Keyboard_Input == "1") - { - if(!access(".\\WorkPath\\Encrypt\\InputFile\\",0)) - { - std :: cout << "Building and Loading Folder 20%" << endl; - } - else - { - system("@Mkdir .\\WorkPath\\Encrypt\\InputFile\\"); - } - - if(!access(".\\WorkPath\\Encrypt\\OutputFile\\",0)) - { - std :: cout << "Building and Loading Folder 40%" << endl; - } - else - { - system("@Mkdir .\\WorkPath\\Encrypt\\OutputFile\\"); - } - - if(!access(".\\WorkPath\\Decrypt\\InputFile\\",0)) - { - std :: cout << "Building and Loading Folder 60%" << endl; - } - else - { - system("@Mkdir .\\WorkPath\\Decrypt\\InputFile\\"); - } - - if(!access(".\\WorkPath\\Decrypt\\OutputFile\\",0)) - { - std :: cout << "Building and Loading Folder 80%" << endl; - } - else - { - system("@Mkdir .\\WorkPath\\Decrypt\\OutputFile\\"); - } - - if(!access(".\\File-Key-Record-Log\\",0)) - { - std :: cout << "Building and Loading Folder 100%" << endl; - } - else - { - system("@Mkdir .\\File-Key-Record-Log\\"); - } - - system("cls"); - system("color 1A"); - - ConsoleTableColorSet(0,0,0); - std :: cout << "Please input >>> the source file name + file extension name.\nDo not enter spaces!\n:" << endl; - std :: cout << "输入要加密的文件名+文件扩展名,不要输入空格!" << endl; - std :: cin >> E_SourceFileName; - - std :: cout << "Please input >>> the source file name, not the file extension name!\nDo not enter spaces!\n:" << endl; - std :: cout << "输入要加密的文件主要名,不是文件扩展名!不要输入空格!" << endl; - std :: cin >> E_SourceFileMainName; - - std :: cout << "Please input >>> the file extension name.\nDo not enter spaces!\n:" << endl; - std :: cout << "输入要加密的文件扩展名,不要输入空格!" << endl; - std :: cin >> E_SourceFileExtendedName; - system("cls"); - - std :: cout << "正在记录并导出,源文件名称......\n[警告!]在进行本次操作后,请下次选择同样名称的加密文件,进行解密文件操作!\n否则,在那之前,请立即禁止使用加密文件功能!" << endl; - std :: cout << "Recording and exporting, source file name......\n[Warning!]After doing this operation, please select the same name next time the encrypted file, decrypt the file operation!\nOtherwise, before that, please immediately disable the use of encrypted file function" << endl; - std :: cout << "您是否接受这个协议?[键盘Enter继续] 或者 [关闭程序]......" << endl; - std :: cout << "Whether you accept this agreement?[Keyboard Enter Continue] Or [Close this program]......" << endl; - system("pause"); - system("cls"); - - ofstream SourceFileNameTempOutput; - SourceFileNameTempOutput.open(".\\SourceFileName_Temp.INI"); - SourceFileNameTempOutput << E_SourceFileName << endl; - SourceFileNameTempOutput.close(); - SourceFileNameTempOutput.open(".\\SourceFileMainName_Temp.INI"); - SourceFileNameTempOutput << E_SourceFileMainName << endl; - SourceFileNameTempOutput.close(); - SourceFileNameTempOutput.open(".\\SourceFileExtendedName_Temp.INI"); - SourceFileNameTempOutput << E_SourceFileExtendedName << endl; - SourceFileNameTempOutput.close(); - - ConsoleTableColorSet(0,0,1); - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥,不要输入空格!" << endl; //密钥是用户自己定义的,(长度小于128)。可以随意给需要加密的文件添加密钥 - std :: cout << "Please input >>> the key,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> E_KEY; - - ConsoleTableColorSet(0,1,0); - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥2,不要输入空格!" << endl; - std :: cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> E_KEY2; - - ConsoleTableColorSet(0,1,1); - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥3,不要输入空格!" << endl; - std :: cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> E_KEY3; - - ConsoleTableColorSet(1,0,0); - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥4,不要输入空格!" << endl; - std :: cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> E_KEY4; - - ConsoleTableColorSet(1,0,1); - std :: cout << "\n"; - std :: cout << "Please output >>> file extension name.\nDo not enter spaces!\n[.TSMY-ENCRYPTED]:" << endl; - std :: cout << "输出文件扩展名,不要输入空格[.TSMY-ENCRYPTED]:" << endl; //给加密后的文件输出文件扩展名,并保存 - std :: cin >> E_TargetFileExtendedName; - if(E_TargetFileExtendedName == " ") - { - string E_TargetFileAddExtendedName = ".TSMY-ENCRYPTED"; - E_TargetFileExtendedName = E_TargetFileAddExtendedName; - } - - system("cls"); - - string E_SourceFileStringPath = E_IF_PATH + E_SourceFileName; - string E_TargetFileStringPath = E_OF_PATH + E_SourceFileName + E_TargetFileExtendedName; - - const char *E_SourceFileCharPath = E_SourceFileStringPath.c_str(); - const char *E_TargetFileCharPath = E_TargetFileStringPath.c_str(); - - /*char *E_SourceFileLastNameOutput; //最后读写的文件名 - strcpy(E_SourceFileLastNameOutput,E_SourceFileCharPath); - char *E_TargetFileLastNameOutput; //最后保存的加密后文件名 - strcpy(E_TargetFileLastNameOutput,E_TargetFileCharPath);*/ - - ConsoleTableColorSet(1,1,0); - std :: cout << "正在记录并导出,本次用于文件加密,3个密钥字符串......" << endl; - std :: cout << "Is being recorded and exported, this time for file encryption, 3 key string......" << endl; - ofstream PasswordOutputKeyFile; - PasswordOutputKeyFile.open(".\\File-Key-Record-Log\\ENCRYPTION-DECRYPTIPN-PASSWORD.KEY.TXT"); - PasswordOutputKeyFile << "Twlilght_Yujiang File Lock Password [Key String] Save\n" << endl; - PasswordOutputKeyFile << "\n" << endl; - PasswordOutputKeyFile << "Source Input File Name and Path: " << E_SourceFileStringPath << "\n" << endl; - PasswordOutputKeyFile << "EncryptFile: New Output Target File Name and Path: " << E_TargetFileStringPath << "\n" << endl; - PasswordOutputKeyFile << "Key string1 [Password1]: " << E_KEY << "\n" << endl; - PasswordOutputKeyFile << "Key string2 [Password2]: " << E_KEY2 << "\n" << endl; - PasswordOutputKeyFile << "Key string3 [Password3]: " << E_KEY3 << "\n" << endl; - PasswordOutputKeyFile << "Key string4 [Password3]: " << E_KEY4 << "\n" << endl; - PasswordOutputKeyFile << "<******************************************************************************************>" << "\n" << endl; - PasswordOutputKeyFile.close(); - - ConsoleTableColorSet(1,1,1); - std :: cout << "Please wait, read and write in the file......" << endl; - std :: cout << "请等待,文件读写中......" << endl; - getchar(); - - if(RunEncryptFile(E_SourceFileCharPath, E_KEY, E_KEY2, E_KEY3, E_KEY4, E_TargetFileCharPath)) - { - printf("恭喜你,文件[%s]加密成功,保存在[%s]。\n", E_SourceFileCharPath, E_TargetFileCharPath); - printf("Congratulations, the file [%s] is encrypted successfully, saved in [%s]. \n", E_SourceFileCharPath, E_TargetFileCharPath); - getchar(); - system("pause"); - system("cls"); - goto ProgramMainMenu; - } - } - - if(Load_User_Keyboard_Input == "2") - { - if(!access(".\\WorkPath\\Encrypt\\InputFile\\",0)) - { - std :: cout << "Building and Loading Folder 20%" << endl; - } - else - { - system("@Mkdir .\\WorkPath\\Encrypt\\InputFile\\"); - } - - if(!access(".\\WorkPath\\Encrypt\\OutputFile\\",0)) - { - std :: cout << "Building and Loading Folder 40%" << endl; - } - else - { - system("@Mkdir .\\WorkPath\\Encrypt\\OutputFile\\"); - } - - if(!access(".\\WorkPath\\Decrypt\\InputFile\\",0)) - { - std :: cout << "Building and Loading Folder 60%" << endl; - } - else - { - system("@Mkdir .\\WorkPath\\Decrypt\\InputFile\\"); - } - - if(!access(".\\WorkPath\\Decrypt\\OutputFile\\",0)) - { - std :: cout << "Building and Loading Folder 80%" << endl; - } - else - { - system("@Mkdir .\\WorkPath\\Decrypt\\OutputFile\\"); - } - - if(!access(".\\File-Key-Record-Log\\",0)) - { - std :: cout << "Building and Loading Folder 100%" << endl; - } - else - { - system("@Mkdir .\\File-Key-Record-Log\\"); - } - - system("cls"); - system("color 1A"); - - ConsoleTableColorSet(1,1,1); - std :: cout << "Please input >>> the source file name + file extension name.\nDo not enter spaces!\n:" << endl; - std :: cout << "输入要解密的文件名+文件扩展名,不要输入空格!" << endl; - std :: cin >> D_SourceFileName; - - ConsoleTableColorSet(1,1,0); - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥,不要输入空格!" << endl; //密钥是用户自己定义的,可以随意给需要解密的文件输入密钥 - std :: cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> D_KEY; - - ConsoleTableColorSet(1,0,1); - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥2,不要输入空格!" << endl; - std :: cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> D_KEY2; - - ConsoleTableColorSet(1,0,0); - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥3,不要输入空格!" << endl; - std :: cout << "Please input >>> the key,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> D_KEY3; - - ConsoleTableColorSet(0,1,1); - std :: cout << "\n"; - std :: cout << "输入(长度小于128)密钥4,不要输入空格!" << endl; - std :: cout << "Please input >>> the key,Do not enter spaces!\n(length less than 128):" << endl; - std :: cin >> D_KEY4; - - system("cls"); - - ConsoleTableColorSet(0,1,0); - - std :: cout << "\n"; - std :: cout << "如果在当前文件夹下配置文件[.\\*.INI]不存在,程序就不会帮您自动恢复原来的文件名称。\n你需要重新输入文件名!" << endl; - std :: cout << "If the configuration file [.\\*.INI] does not exist in the current folder, the program will not automatically restore the original file name.\nYou need to re-enter the file name!" << endl; - std :: cout << "Please output >>> target file main name,not the file extension name!\nDo not enter spaces!\n[DATA-DECRYPTED]:" << endl; - std :: cout << "输出文件主要名,不是文件扩展名,不要输入空格[DATA-TSMY-DECRYPTED]!" << endl; //给解密后的文件输出主要文件名,并保存 - if(!access(".\\SourceFileMainName_Temp.INI",0)) - { - //char TFMN_Buffer[256]; - ifstream LoadSourceFileNameConfigure(".\\SourceFileMainName_Temp.INI",ios::in); - if(LoadSourceFileNameConfigure.fail()) - { - std :: cout << "Error End" << endl; - } - while(!LoadSourceFileNameConfigure.eof()) - { - LoadSourceFileNameConfigure >> D_TargetFileMainName; - //LoadSourceFileNameConfigure.getline(TFMN_Buffer,256,'\n'); //getline(char *,int,char) 表示该行字符达到256个或遇到换行就结束 - //D_TargetFileMainName = TFMN_Buffer; - } - LoadSourceFileNameConfigure.close(); - } - else - { - std :: cout << "配置文件" << ".\\SourceFileMainName_Temp.INI" << "未找到!\n" << "请重新输入名称!" << endl; - std :: cout << "Configuration file" << ".\\SourceFileMainName_Temp.INI" << "Not found!\n" << "Please re-enter the name!" << endl; - HANDLE hFILE = CreateFile(".\\SourceFileMainName_Temp.INI",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); - std :: cin >> D_TargetFileMainName; - - } - - system("cls"); - - std :: cout << "\n"; - std :: cout << "如果在当前文件夹下配置文件[.\\*.INI]不存在,程序就不会帮您自动恢复原来的文件名称。\n你需要重新输入文件名!" << endl; - std :: cout << "If the configuration file [.\\*.INI] does not exist in the current folder, the program will not automatically restore the original file name.\nYou need to re-enter the file name!" << endl; - std :: cout << "Please output >>> target file temp add name.\nDo not enter spaces!\n[-DECRYPTED]:" << endl; - std :: cout << "输出文件临时添加名,不要输入空格[-TSMY-DECRYPTED]!" << endl; //给解密后的文件输出文件临时添加名,并保存 - std :: cout << "Prevent source encrypted files from being overwritten" << endl; - std :: cout << "防止源加密文件被覆盖" << endl; - std :: cin >> D_TargetFileTempName; - if(D_TargetFileTempName == " ") - { - string D_TargetFileAddName = "-TSMY-DECRYPTED"; - D_TargetFileTempName = D_TargetFileAddName; - } - - system("cls"); - - std :: cout << "如果在当前文件夹下配置文件[.\\*.INI]不存在,程序就不会帮您自动恢复原来的文件名称。\n你需要重新输入文件名!" << endl; - std :: cout << "If the configuration file [.\\*.INI] does not exist in the current folder, the program will not automatically restore the original file name.\nYou need to re-enter the file name!" << endl; - std :: cout << "Please output >>> target file extension name!\nDo not enter spaces!\n[-DECRYPTED]:" << endl; - std :: cout << "输出文件扩展名,不要输入空格[-TSMY-DECRYPTED]!" << endl; //给解密后的文件输出文件扩展名,并保存 - if(!access(".\\SourceFileExtendedName_Temp.INI",0)) - { - ifstream LoadSourceFileNameConfigure(".\\SourceFileExtendedName_Temp.INI",ios::in); - //char TFEN_Buffer[256]; - if(LoadSourceFileNameConfigure.fail()) - { - std :: cout << "Error End" << endl; - } - while(!LoadSourceFileNameConfigure.eof()) - { - LoadSourceFileNameConfigure >> D_TargetFileExtendedName; - //LoadSourceFileNameConfigure.getline(TFEN_Buffer,256,'\n'); //getline(char *,int,char) 表示该行字符达到256个或遇到换行就结束 - //D_TargetFileExtendedName = TFEN_Buffer; - } - LoadSourceFileNameConfigure.close(); - } - else - { - std :: cout << "配置文件" << ".\\SourceFileExtendedName_Temp.INI" << "未找到!\n" << "请重新输入名称!" << endl; - std :: cout << "Configuration file" << ".\\SourceFileExtendedName_Temp.INI" << "Not found!\n" << "Please re-enter the name!" << endl; - HANDLE hFILE = CreateFile(".\\SourceFileExtendedName_Temp.INI",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); - std :: cin >> D_TargetFileExtendedName; - } - - system("cls"); - - string D_SourceFileStringPath = D_IF_PATH + D_SourceFileName; - string D_TargetFileStringPath = D_OF_PATH + D_TargetFileMainName + D_TargetFileTempName + D_TargetFileExtendedName; - - const char *D_SourceFileCharPath = D_SourceFileStringPath.c_str(); - const char *D_TargetFileCharPath = D_TargetFileStringPath.c_str(); - - /*char *D_SourceFileLastNameOutput; //最后读写的文件名 - strcpy(D_SourceFileLastNameOutput,D_SourceFileCharPath); - char *D_TargetFileLastNameOutput; //最后临时保存的解密后的文件名 - strcpy(D_TargetFileLastNameOutput,D_TargetFileCharPath);*/ - - ConsoleTableColorSet(0,0,1); - std :: cout << "Please wait, read and write in the file......" << endl; - std :: cout << "请等待,文件读写中......" << endl; - getchar(); - - if(RunDecryptFile(D_SourceFileCharPath, D_KEY, D_KEY2, D_KEY3, D_KEY4, D_TargetFileCharPath)) - { - printf("恭喜你,文件[%s]解密成功,保存在[%s]。\n", D_SourceFileCharPath, D_TargetFileCharPath); - printf("Congratulations, the file [%s] is decrypted successfully, saved in [%s]. \n", D_SourceFileCharPath, D_TargetFileCharPath); - getchar(); - system("pause"); - system("cls"); - goto ProgramMainMenu; - } - } - if(Load_User_Keyboard_Input == "3") - { - Instruction_Manual_Language_Restart: - system("cls"); - std :: cout << "欢迎你的到来! 这是本程序的说明手册[Beta Version 3.0],请务必在使用前,仔细阅读" << endl; - std :: cout << "Welcome to your arrival! This is the instruction manual [Beta Version 3.0] of this program, please be sure to read carefully before using it" << endl; - std :: cout << "" << endl; - std :: cout << "enUS----------English 英文" << endl; - std :: cout << "zhCN----------Chinese 中文" << endl; - std :: cout << "MENU----------Back Main Menu 返回主菜单" << endl; - string Instruction_Manual_Language; - std :: cin >> Instruction_Manual_Language; - if(Instruction_Manual_Language == "enUS") - { - system("cls"); - system("color 67"); - std :: cout << "When the program executes the function of encrypting the file or decrypting the file, it will create the workspace folder, input the folder, output the folder.\n" << endl; - std :: cout << "When the program encrypts the file or decrypts the file and waits, the program is reading and writing the file in the background.\nNever close the program at this time! Otherwise your data is damaged and bear the consequences.\nIt is recommended that you after the data backup, use this program to encrypt the file or decrypt the file!\n" << endl; - system("pause"); - system("cls"); - - } - if(Instruction_Manual_Language == "zhCN") - { - system("cls"); - system("color 17"); - std :: cout << "当程序执行加密文件或解密文件的功能时,将创建工作空间文件夹,输入文件夹,输出文件夹。\n" << endl; - std :: cout << "当程序加密文件或解密文件并且等待时,程序正在后台读取和写入文件。这个时候,永远不要关闭这个程序!\n否则您的数据被损坏并承担后果。建议您在进行数据备份之后,用这个程序加密文件或解密文件!\n" << endl; - system("pause"); - system("cls"); - - } - if(Instruction_Manual_Language == "MENU") - { - system("cls"); - goto ProgramMainMenu; - } - else - { - if(Instruction_Manual_Language != "enUS","zhCN") - { - ConsoleTableColorSet(0,0,0); - goto Instruction_Manual_Language_Restart; - } - } - - } - if(Load_User_Keyboard_Input == "4") - { - Clear_Workspace_Restart: - string Clear_Workspace; - system("color 0C"); - std :: cout << "[警告!]即将进行的操作,会选中 文件夹,然后永久的删除所有数据!\n" << endl; - std :: cout << "包括源文件、生成的加密文件、生成的解密文件、密码日志、配置\n" << endl; - std :: cout << "如果你知道风险,请按键盘 [Y键继续 N键返回]\n[ Yes / No ]" << endl; - - std :: cout << "[Warning!] The upcoming operation will select the and , and then permanently delete all the data!\n" << endl; - std :: cout << "Including source files, generated encrypted files, generated decrypted files, password logs, configuration\n" << endl; - std :: cout << "If you know the risk, press the keypad [Y key to continue N key to return]\n[Yes / No]" << endl; - std :: cin >> Clear_Workspace; - if(Clear_Workspace == "Y","y") - { - DeleteFile(".\\SourceFileName_Temp.INI"); - DeleteFile(".\\SourceFileMainName_Temp.INI"); - DeleteFile(".\\SourceFileExtendedName_Temp.INI"); - - system("@Del /s /f /q .\\File-Key-Record-Log\\*.*"); - system("@Del /s /f /q .\\WorkPath\\*.*"); - - system("@Del /s /f /q .\\WorkPath\\Encrypt\\*.*"); - system("@Del /s /f /q .\\WorkPath\\Encrypt\\InputFile\\*.*"); - system("@Del /s /f /q .\\WorkPath\\Encrypt\\OutputFile\\*.*"); - - system("@Del /s /f /q .\\WorkPath\\Decrypt\\*.*"); - system("@Del /s /f /q .\\WorkPath\\Decrypt\\InputFile\\*.*"); - system("@Del /s /f /q .\\WorkPath\\Decrypt\\OutputFile\\*.*"); - - system("@Rmdir /s /q .\\File-Key-Record-Log\\"); - - system("@Rd /s /q .\\WorkPath\\Encrypt\\OutputFile\\"); - system("@Rd /s /q .\\WorkPath\\Encrypt\\InputFile\\"); - system("@Rd /s /q .\\WorkPath\\Encrypt\\"); - - system("@Rd /s /q .\\WorkPath\\Decrypt\\OutputFile\\"); - system("@Rd /s /q .\\WorkPath\\Decrypt\\InputFile\\"); - system("@Rd /s /q .\\WorkPath\\Decrypt\\"); - system("@Rd /s /q .\\WorkPath\\"); - - system("cls"); - - goto ProgramMainMenu; - - } - if(Clear_Workspace == "N","n") - { - goto ProgramMainMenu; - } - else - { - if(Clear_Workspace != "Y","N","y","n") - { - goto Clear_Workspace_Restart; - } - } - - - } - if(Load_User_Keyboard_Input == "5") - { - return 0; - } - else - { - if(Load_User_Keyboard_Input != "1","2","3","4") - { - ConsoleTableColorSet(0,0,0); - std :: cout << "User Keyboard Input Error !" << endl; - getchar(); - exit(1); - } - } -} - -#include "Main_3_By_Twlilght_Yujiang.hpp" diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.hpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.hpp deleted file mode 100644 index bceb4b0..0000000 --- a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_3_By_Twlilght_Yujiang.hpp +++ /dev/null @@ -1,487 +0,0 @@ -/******************************************* -* 加密文件 -* -* E_SourceFileName 需要加密的文件名 -* E_KEY 密钥 -* E_TargetFileNewName 加密完成后要保存的文件名 -* -* @return 加密成功或失败的数字表示 -* -* 0 = 加密失败 -* 1 = 加密成功 -********************************************/ - - int RunEncryptFile(const char *E_SourceFileCharPath, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_KEY4, const char *E_TargetFileCharPath) - { - FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 - char buffer[1024]; //缓冲区,用于存放从文件读取的数据 - - int FileByteData, //每次从文件中读取的字节数 - RTNOC, //运行循环次数 (Run The Number Of Cycles) - KeyLength = strlen(E_KEY), //密钥的长度 - KeyLength2 = strlen(E_KEY2), - KeyLength3 = strlen(E_KEY3), - KeyLength4 = strlen(E_KEY4); - - FilePointerSource = fopen(E_SourceFileCharPath, "rb"); //以二进制方式读取文件 - if(FilePointerSource == NULL) - { - printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", E_SourceFileCharPath); - printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", E_SourceFileCharPath); - getchar(); - return 0; - } - - FilePointerTarget = fopen(E_TargetFileCharPath, "wb+"); //以二进制方式写入文件 - if(FilePointerTarget == NULL) - { - printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", E_TargetFileCharPath); - printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", E_TargetFileCharPath); - getchar(); - return 0; - } - -/*加密算法开始*/ - -/*****************************************************************************buffer[RTNOC]******************************************************************************/ - -//运行大型加密模块 -//Run large encryption module - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - int NOIEM; //初始加密模块次数 (Number of initial encryption modules) - int MAX_NOT_E_MODULE = 65; //运行加密模块循环次数 (The maximum number of times the encryption module is running) - - for(NOIEM = 0;NOIEM < MAX_NOT_E_MODULE;NOIEM++) - { - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 - { - buffer[RTNOC] /= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 - { - buffer[RTNOC] -= E_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - - - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 - { - buffer[RTNOC] /= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 - { - buffer[RTNOC] -= E_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 - { - buffer[RTNOC] /= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 - { - buffer[RTNOC] -= E_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥4在缓冲区中计算 -//The file and key4 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += E_KEY4[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= E_KEY4[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= E_KEY4[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 - { - buffer[RTNOC] /= E_KEY4[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 - { - buffer[RTNOC] -= E_KEY4[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - }; - -/***********************************************************************************************************************************************************/ - -/*加密算法结束*/ - - fclose(FilePointerSource); - fclose(FilePointerTarget); - - DeleteFile(E_SourceFileCharPath); - - return 1; - } - - int RunDecryptFile(const char *D_SourceFileCharPath, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_KEY4, const char *D_TargetFileCharPath) - { - FILE *FilePointerSource, *FilePointerTarget; //要打开的文件的指针 - char buffer[1024]; //缓冲区,用于存放从文件读取的数据 - - int FileByteData, //每次从文件中读取的字节数 - RTNOC, //循环次数 - KeyLength = strlen(D_KEY), //密钥的长度 - KeyLength2 = strlen(D_KEY2), - KeyLength3 = strlen(D_KEY3), - KeyLength4 = strlen(D_KEY4); - - FilePointerSource = fopen(D_SourceFileCharPath, "rb"); //以二进制方式读取文件 - if(FilePointerSource == NULL) - { - printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", D_SourceFileCharPath); - printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", D_SourceFileCharPath); - getchar(); - return 0; - } - - FilePointerTarget = fopen(D_TargetFileCharPath, "wb+"); //以二进制方式写入文件 - if(FilePointerTarget == NULL) - { - printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", D_TargetFileCharPath); - printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", D_TargetFileCharPath); - getchar(); - return 0; - } - -/******************************************* -* 解密文件 -* -* D_SourceFileName 需要解密的文件名 -* D_KEY 密钥 -* D_TargetFileNewName 解密完成后要保存的文件名 -* -* @return 解密成功或失败的数字表示 -* -* 0 = 解密失败 -* 1 = 解密成功 -********************************************/ - -/*解密算法开始*/ - -/***********************************************************************************************************************************************************/ - -//运行大型解密模块 -//Run large decryption module - -//文件和密钥在缓冲区中计算 -//The file and key are counted in Buffer - - int NOIDM; //初始解密模块次数 (Number of initial decryption modules) - int MAX_NOT_D_MODULE = 65; //运行解密模块循环次数 (The maximum number of times the decryption module is running) - - for(NOIDM = 0;NOIDM < MAX_NOT_D_MODULE;NOIDM++) - { - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 - { - buffer[RTNOC] -= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 - { - buffer[RTNOC] /= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += D_KEY[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - - -//文件和密钥2在缓冲区中计算 -//The file and key2 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 - { - buffer[RTNOC] -= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 - { - buffer[RTNOC] /= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += D_KEY2[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥3在缓冲区中计算 -//The file and key3 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 - { - buffer[RTNOC] -= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 - { - buffer[RTNOC] /= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += D_KEY3[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - -//文件和密钥4在缓冲区中计算 -//The file and key4 are counted in Buffer - - while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 - { - buffer[RTNOC] -= D_KEY4[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递除运算 - { - buffer[RTNOC] /= D_KEY4[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 - { - buffer[RTNOC] ^= D_KEY4[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递乘运算 - { - buffer[RTNOC] *= D_KEY4[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 - { - for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 - { - buffer[RTNOC] += D_KEY4[RTNOC]; - } - fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 - } - }; - -/***********************************************************************************************************************************************************/ - -/*解密算法结束*/ - - fclose(FilePointerSource); - fclose(FilePointerTarget); - - DeleteFile(D_SourceFileCharPath); - - return 1; - } diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_EODF3_By_TDOM.cpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_EODF3_By_TDOM.cpp new file mode 100644 index 0000000..56835ca --- /dev/null +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/Main_EODF3_By_TDOM.cpp @@ -0,0 +1,720 @@ +/**************************************************************************** +Read Me - About This Source Code File + +Chinese涓枃: +璁$畻鏈鸿瑷绫诲瀷: C++ +绋嬪簭鏂囦欢鍚: File_Lock +绋嬪簭骞冲彴绫诲瀷: Windows 鍛戒护琛屾帶鍒跺彴 +绋嬪簭瀹為檯浣滅敤: 鏂囦欢瀵圭О寮忓姞瀵嗚В瀵 +鐗堟湰: Beta 3.0 +婧愪唬鐮佷慨鏀规椂闂: 2019-5-31 +浣滆: Twilight-Dream-Of-Magic + +English鑻辨枃: +Computer Language Type: C ++ +Program File Name: File_Lock +Program Platform Type: Windows Command Line Console +The actual role of the program: file symmetric encryption and decryption +Version: Beta 3.0 +Source code modified by: 2019-5-31 +Author: Twilight-Dream-Of-Magic +*****************************************************************************/ + +//#include //MakeSureDirectoryPathExists(""); +//#pragma comment(lib, "ImageHlp.lib") + +#include "EODF3_By_TDOM.hpp" + +using namespace std; + +//typedef unsigned char byte; + +int RunEncryptFile(const char *E_SourceFileCharPath, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_KEY4, const char *E_TargetFileCharPath); +int RunDecryptFile(const char *D_SourceFileCharPath, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_KEY4, const char *D_TargetFileCharPath); + +//浠ヤ笅鍙橀噺,搴旂敤鍒版枃浠惰鍔犲瘑鏃 +//The following variables apply when the file is encrypted +//***澹版槑浠g爜-寮濮 Declare the code - the beginning*** +string E_IF_PATH = ".\\WorkPath\\Encrypt\\InputFile\\", //鍔犲瘑涔嬪墠锛屾枃浠剁殑璺緞 Before encrypting the path of the file +E_OF_PATH = ".\\WorkPath\\Encrypt\\OutputFile\\"; //鍔犲瘑涔嬪悗锛屾枃浠剁殑璺緞 After encrypting the path of the file + +string E_SourceFileName, // 婧愭枃浠跺悕 +E_SourceFileMainName, // 婧愭枃浠朵富瑕佸悕 +E_SourceFileExtendedName, // 婧愭枃浠舵墿灞曞悕 +E_TargetFileExtendedName; // 鐩爣鏂囦欢鎵╁睍鍚 + +char E_KEY[256], //File (Encryption or Encrypted) key 鏂囦欢鍔犲瘑瀵嗛挜 +E_KEY2[256], +E_KEY3[256], +E_KEY4[256]; +//***澹版槑浠g爜-缁撴潫 Declare the code - end*** + +//浠ヤ笅鍙橀噺,搴旂敤鍒版枃浠惰瑙e瘑鏃 +//The following variables apply when the file is decrypted +//***澹版槑浠g爜-寮濮 Declare the code - the beginning*** +string D_IF_PATH = ".\\WorkPath\\Decrypt\\InputFile\\", //瑙e瘑涔嬪墠锛屾枃浠剁殑璺緞 Before decrypting the path of the file +D_OF_PATH = ".\\WorkPath\\Decrypt\\OutputFile\\"; //瑙e瘑涔嬪悗锛屾枃浠剁殑璺緞 After decrypting the path of the file + +string D_SourceFileName, //婧愭枃浠跺悕 +D_TargetFileMainName, //鐩爣鏂囦欢涓昏鍚 +D_TargetFileTempName, //鐩爣鏂囦欢涓存椂娣诲姞鍚 +D_TargetFileExtendedName; //鐩爣鏂囦欢婧愭墿灞曞悕 + +char D_KEY[256], //File (Decryption or Decrypted) key 鏂囦欢瑙e瘑瀵嗛挜 +D_KEY2[256], +D_KEY3[256], +D_KEY4[256]; +//***澹版槑浠g爜-缁撴潫 Declare the code - end*** + +/****************************************************************************************************************************************************************/ + +void ConsoleTableColorSet(int R, int G, int B) +{ + if (R < 0) R = 0; + if (R > 1) R = 1; + + if (G < 0) G = 0; + if (G > 1) G = 1; + + if (B < 0) B = 0; + if (B > 1) B = 1; + + if (R == 1 && G == 1 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + } + else if (R == 1 && G == 1 && B == 0) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); + } + else if (R == 1 && G == 0 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE); + } + else if (R == 0 && G == 1 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE); + } + else if (R == 1 && G == 0 && B == 0) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED); + } + else if (R == 0 && G == 1 && B == 0) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN); + } + else if (R == 0 && G == 0 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE); + } + else + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY); + } +} + +void CleanFileFromThisWorkspace() +{ + DeleteFile(".\\SourceFileName.CONFIGFILE"); + DeleteFile(".\\SourceFileMainName.CONFIGFILE"); + DeleteFile(".\\SourceFileExtendedName.CONFIGFILE"); + + system("@Del /s /f /q .\\File-Key-Record-Log\\*.*"); + system("@Del /s /f /q .\\WorkPath\\*.*"); + + system("@Del /s /f /q .\\WorkPath\\Encrypt\\*.*"); + system("@Del /s /f /q .\\WorkPath\\Encrypt\\InputFile\\*.*"); + system("@Del /s /f /q .\\WorkPath\\Encrypt\\OutputFile\\*.*"); + + system("@Del /s /f /q .\\WorkPath\\Decrypt\\*.*"); + system("@Del /s /f /q .\\WorkPath\\Decrypt\\InputFile\\*.*"); + system("@Del /s /f /q .\\WorkPath\\Decrypt\\OutputFile\\*.*"); + + system("@Rmdir /s /q .\\File-Key-Record-Log\\"); + + system("@Rmdir /s /q .\\WorkPath\\Encrypt\\OutputFile\\"); + system("@Rmdir /s /q .\\WorkPath\\Encrypt\\InputFile\\"); + system("@Rmdir /s /q .\\WorkPath\\Encrypt\\"); + + system("@Rmdir /s /q .\\WorkPath\\Decrypt\\OutputFile\\"); + system("@Rmdir /s /q .\\WorkPath\\Decrypt\\InputFile\\"); + system("@Rmdir /s /q .\\WorkPath\\Decrypt\\"); + system("@Rmdir /s /q .\\WorkPath\\"); + + system("cls"); +} + +int main() +{ + ProgramMainMenu: + + string Load_User_Keyboard_Input; + + system("color 0A"); + system("cls"); + + std::cout << "----------------------------------------" << endl; + std::cout << "Enter 1 Encrypt File" << endl; + std::cout << "1.鍔犲瘑鏂囦欢\n" << endl; + std::cout << "Enter 2 Decrypt File" << endl; + std::cout << "2.瑙e瘑鏂囦欢\n" << endl; + std::cout << "Enter 3 Use The Information Manual" << endl; + std::cout << "3.浣跨敤淇℃伅璇存槑鎵嬪唽\n" << endl; + std::cout << "Enter 4 Clean Up The Workspace[To Restore The Initial State]" << endl; + std::cout << "4.娓呯悊宸ヤ綔绌洪棿[鎭㈠鍒濆鐘舵乚\n" << endl; + std::cout << "Enter 5 Exit Program" << endl; + std::cout << "5.閫鍑虹▼搴廫n" << endl; + std::cout << "----------------------------------------" << endl; + std::cout << "System:Input And Output/Enter>"; + + std::cin >> Load_User_Keyboard_Input; + cin.get(); + +/****************************************************************************************************************************************************************/ + + if (Load_User_Keyboard_Input == "1") + { + if (!access(".\\WorkPath\\Encrypt\\InputFile\\", 0)) + { + std::cout << "Building and Loading Folder 20%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Encrypt\\InputFile\\"); + } + + if (!access(".\\WorkPath\\Encrypt\\OutputFile\\", 0)) + { + std::cout << "Building and Loading Folder 40%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Encrypt\\OutputFile\\"); + } + + if (!access(".\\WorkPath\\Decrypt\\InputFile\\", 0)) + { + std::cout << "Building and Loading Folder 60%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Decrypt\\InputFile\\"); + } + + if (!access(".\\WorkPath\\Decrypt\\OutputFile\\", 0)) + { + std::cout << "Building and Loading Folder 80%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Decrypt\\OutputFile\\"); + } + + if (!access(".\\File-Key-Record-Log\\", 0)) + { + std::cout << "Building and Loading Folder 100%" << endl; + } + else + { + system("@Mkdir .\\File-Key-Record-Log\\"); + } + + system("cls"); + system("color 1A"); + + ConsoleTableColorSet(0, 0, 0); + std::cout << "Please input >>> the source file name + file extension name.\nDo not enter spaces!\n:" << endl; + std::cout << "杈撳叆瑕佸姞瀵嗙殑鏂囦欢鍚+鏂囦欢鎵╁睍鍚嶏紝涓嶈杈撳叆绌烘牸!" << endl; + std::cin >> E_SourceFileName; + + std::cout << "Please input >>> the source file name, not the file extension name!\nDo not enter spaces!\n:" << endl; + std::cout << "杈撳叆瑕佸姞瀵嗙殑鏂囦欢涓昏鍚嶏紝涓嶆槸鏂囦欢鎵╁睍鍚嶏紒涓嶈杈撳叆绌烘牸!" << endl; + std::cin >> E_SourceFileMainName; + + std::cout << "Please input >>> the file extension name.\nDo not enter spaces!\n:" << endl; + std::cout << "杈撳叆瑕佸姞瀵嗙殑鏂囦欢鎵╁睍鍚嶏紝涓嶈杈撳叆绌烘牸!" << endl; + std::cin >> E_SourceFileExtendedName; + system("cls"); + + std::cout << "姝e湪璁板綍骞跺鍑猴紝婧愭枃浠跺悕绉......\n[璀﹀憡!]鍦ㄨ繘琛屾湰娆℃搷浣滃悗锛岃涓嬫閫夋嫨鍚屾牱鍚嶇О鐨勫姞瀵嗘枃浠讹紝杩涜瑙e瘑鏂囦欢鎿嶄綔!\n鍚﹀垯锛屽湪閭d箣鍓嶏紝璇风珛鍗崇姝娇鐢ㄥ姞瀵嗘枃浠跺姛鑳斤紒" << endl; + std::cout << "Recording and exporting, source file name......\n[Warning!]After doing this operation, please select the same name next time the encrypted file, decrypt the file operation!\nOtherwise, before that, please immediately disable the use of encrypted file function" << endl; + std::cout << "鎮ㄦ槸鍚︽帴鍙楄繖涓崗璁?[閿洏Enter缁х画] 鎴栬 [鍏抽棴绋嬪簭]......" << endl; + std::cout << "Whether you accept this agreement?[Keyboard Enter Continue] Or [Close this program]......" << endl; + + system("pause"); + system("cls"); + + ofstream SourceFileNameTemporarySave; + SourceFileNameTemporarySave.open(".\\SourceFileName.CONFIGFILE"); + SourceFileNameTemporarySave << E_SourceFileName << endl; + SourceFileNameTemporarySave.close(); + SourceFileNameTemporarySave.open(".\\SourceFileMainName.CONFIGFILE"); + SourceFileNameTemporarySave << E_SourceFileMainName << endl; + SourceFileNameTemporarySave.close(); + SourceFileNameTemporarySave.open(".\\SourceFileExtendedName.CONFIGFILE"); + SourceFileNameTemporarySave << E_SourceFileExtendedName << endl; + SourceFileNameTemporarySave.close(); + + //鍔犲瘑瀵嗛挜鐮佹槸鐢ㄦ埛鑷繁瀹氫箟鐨勶紝(闀垮害灏忎簬256)銆傚彲浠ヤ换鎰忕殑缁欎竴涓渶瑕佸姞瀵嗙殑鏂囦欢娣诲姞涓涓垨澶氫釜鍔犲瘑瀵嗛挜鐮 + //Encryption key code is user-defined, (length less than 256). You can optionally add one or more encryption keys to the one files you want to encrypt + E_KEY_LENTH_IS_INCORRECT: + int E_KEY_CODE_MAX_LENGTH = 256; + + ConsoleTableColorSet(0, 0, 1); + std::cout << "\n"; + std::cout << "杈撳叆(闀垮害灏忎簬256)瀵嗛挜,涓嶈杈撳叆绌烘牸!" << endl; + std::cout << "Please input >>> the key,Do not enter spaces!\n(length less than 256):" << endl; + cin.getline(E_KEY, 256, '\n').get(); + if(strlen(E_KEY) > E_KEY_CODE_MAX_LENGTH) + { + memset(E_KEY,NULL,sizeof(E_KEY)); //Reset This Variable The Value (NULL = 0) + std :: cout << "鍔犲瘑瀵嗛挜鐨勯暱搴︼紝宸茬粡瓒呰繃256浣嶅瓧绗︺ 璇烽噸鏂拌緭鍏ユ墍鏈夊姞瀵嗗瘑閽ワ紒" << endl; + std :: cout << "Encryption key length, has more than 256 characters. Please re-enter the all encryption key!" << endl; + system("pause"); + goto E_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(0, 1, 0); + std::cout << "\n"; + std::cout << "杈撳叆(闀垮害灏忎簬256)瀵嗛挜2,涓嶈杈撳叆绌烘牸!" << endl; + std::cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 256):" << endl; + cin.getline(E_KEY2, 256, '\n').get(); + if(strlen(E_KEY2) > E_KEY_CODE_MAX_LENGTH) + { + memset(E_KEY2,NULL,sizeof(E_KEY2)); //Reset This Variable The Value (NULL = 0) + std :: cout << "鍔犲瘑瀵嗛挜2鐨勯暱搴︼紝宸茬粡瓒呰繃256浣嶅瓧绗︺ 璇烽噸鏂拌緭鍏ユ墍鏈夊姞瀵嗗瘑閽ワ紒" << endl; + std :: cout << "Encryption key2 length, has more than 256 characters. Please re-enter the all encryption key!" << endl; + system("pause"); + goto E_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(0, 1, 1); + std::cout << "\n"; + std::cout << "杈撳叆(闀垮害灏忎簬256)瀵嗛挜3,涓嶈杈撳叆绌烘牸!" << endl; + std::cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 256):" << endl; + cin.getline(E_KEY3, 256, '\n').get(); + if(strlen(E_KEY3) > E_KEY_CODE_MAX_LENGTH) + { + memset(E_KEY3,NULL,sizeof(E_KEY3)); //Reset This Variable The Value (NULL = 0) + std :: cout << "鍔犲瘑瀵嗛挜3鐨勯暱搴︼紝宸茬粡瓒呰繃256浣嶅瓧绗︺ 璇烽噸鏂拌緭鍏ユ墍鏈夊姞瀵嗗瘑閽ワ紒" << endl; + std :: cout << "Encryption key3 length, has more than 256 characters. Please re-enter the all encryption key!" << endl; + system("pause"); + goto E_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(1, 0, 0); + std::cout << "\n"; + std::cout << "杈撳叆(闀垮害灏忎簬256)瀵嗛挜4,涓嶈杈撳叆绌烘牸!" << endl; + std::cout << "Please input >>> the key4,Do not enter spaces!\n(length less than 256):" << endl; + cin.getline(E_KEY4, 256, '\n').get(); + if(strlen(E_KEY4) > E_KEY_CODE_MAX_LENGTH) + { + memset(E_KEY4,NULL,sizeof(E_KEY4)); //Reset This Variable The Value (NULL = 0) + std :: cout << "鍔犲瘑瀵嗛挜4鐨勯暱搴︼紝宸茬粡瓒呰繃256浣嶅瓧绗︺ 璇烽噸鏂拌緭鍏ユ墍鏈夊姞瀵嗗瘑閽ワ紒" << endl; + std :: cout << "Encryption key4 length, has more than 256 characters. Please re-enter the all encryption key!" << endl; + system("pause"); + goto E_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(1, 0, 1); + std::cout << "\n"; + std::cout << "Please output >>> file extension name.\nDo not enter spaces!\n[.TSMY-ENCRYPTED]:" << endl; + std::cout << "杈撳嚭鏂囦欢鎵╁睍鍚,涓嶈杈撳叆绌烘牸[.TSMY-ENCRYPTED]锛" << endl; //缁欏姞瀵嗗悗鐨勬枃浠惰緭鍑烘枃浠舵墿灞曞悕锛屽苟淇濆瓨 Export the file extension to the encrypted file and save it + std::cin >> E_TargetFileExtendedName; + if (E_TargetFileExtendedName == " ") + { + string E_TargetFileAddExtendedName = ".TSMY-ENCRYPTED"; + E_TargetFileExtendedName = E_TargetFileAddExtendedName; + } + + system("cls"); + + string E_SourceFileStringPath = E_IF_PATH + E_SourceFileName; + string E_TargetFileStringPath = E_OF_PATH + E_SourceFileName + E_TargetFileExtendedName; + + const char *E_SourceFileCharPath = E_SourceFileStringPath.c_str(); + const char *E_TargetFileCharPath = E_TargetFileStringPath.c_str(); + + ConsoleTableColorSet(1, 1, 0); + std::cout << "姝e湪璁板綍骞跺鍑猴紝鏈鐢ㄤ簬鏂囦欢鍔犲瘑锛4涓瘑閽ュ瓧绗︿覆......" << endl; + std::cout << "Is being recorded and exported, this time for file encryption, 4 key string......" << endl; + ofstream PasswordSaveToKeyFile; + PasswordSaveToKeyFile.open(".\\File-Key-Record-Log\\ENCRYPTION-DECRYPTION-PASSWORD.KEY.TXT"); + PasswordSaveToKeyFile << "Twilight_Dream File Lock Password [Key String] Save\n" << endl; + PasswordSaveToKeyFile << "\n" << endl; + PasswordSaveToKeyFile << "Source Input File Name and Path: " << E_SourceFileStringPath << "\n" << endl; + PasswordSaveToKeyFile << "EncryptFile: New Output Target File Name and Path: " << E_TargetFileStringPath << "\n" << endl; + PasswordSaveToKeyFile << "Key string1 [Password1]: " << E_KEY << "\n" << endl; + PasswordSaveToKeyFile << "Key string2 [Password2]: " << E_KEY2 << "\n" << endl; + PasswordSaveToKeyFile << "Key string3 [Password3]: " << E_KEY3 << "\n" << endl; + PasswordSaveToKeyFile << "Key string4 [Password4]: " << E_KEY4 << "\n" << endl; + PasswordSaveToKeyFile << "<******************************************************************************************>" << "\n" << endl; + PasswordSaveToKeyFile.close(); + + ConsoleTableColorSet(1, 1, 1); + std::cout << "Please wait, read and write in the file......" << endl; + std::cout << "璇风瓑寰咃紝鏂囦欢璇诲啓涓......" << endl; + cin.get(); + + if (RunEncryptFile(E_SourceFileCharPath, E_KEY, E_KEY2, E_KEY3, E_KEY4, E_TargetFileCharPath) == 1) + { + printf("鎭枩浣狅紝鏂囦欢[%s]鍔犲瘑鎴愬姛锛屼繚瀛樺湪[%s]銆俓n", E_SourceFileCharPath, E_TargetFileCharPath); + printf("Congratulations, the file [%s] is encrypted successfully, saved in [%s]. \n", E_SourceFileCharPath, E_TargetFileCharPath); + cin.get(); + system("pause"); + system("cls"); + goto ProgramMainMenu; + } + } + +/****************************************************************************************************************************************************************/ + + if (Load_User_Keyboard_Input == "2") + { + if (!access(".\\WorkPath\\Encrypt\\InputFile\\", 0)) + { + std::cout << "Building and Loading Folder 20%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Encrypt\\InputFile\\"); + } + + if (!access(".\\WorkPath\\Encrypt\\OutputFile\\", 0)) + { + std::cout << "Building and Loading Folder 40%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Encrypt\\OutputFile\\"); + } + + if (!access(".\\WorkPath\\Decrypt\\InputFile\\", 0)) + { + std::cout << "Building and Loading Folder 60%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Decrypt\\InputFile\\"); + } + + if (!access(".\\WorkPath\\Decrypt\\OutputFile\\", 0)) + { + std::cout << "Building and Loading Folder 80%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Decrypt\\OutputFile\\"); + } + + if (!access(".\\File-Key-Record-Log\\", 0)) + { + std::cout << "Building and Loading Folder 100%" << endl; + } + else + { + system("@Mkdir .\\File-Key-Record-Log\\"); + } + + system("cls"); + system("color 1A"); + + ConsoleTableColorSet(1, 1, 1); + std::cout << "Please input >>> the source file name + file extension name.\nDo not enter spaces!\n:" << endl; + std::cout << "杈撳叆瑕佽В瀵嗙殑鏂囦欢鍚+鏂囦欢鎵╁睍鍚,涓嶈杈撳叆绌烘牸!" << endl; + std::cin >> D_SourceFileName; + + //瑙e瘑瀵嗛挜鐮佹槸鐢辩敤鎴疯嚜宸卞湪鍔犲瘑鏂囦欢姝ラ璁剧疆鐨勩傝繖涓畾涔夛紝鏉ヨ嚜琚姞瀵嗗瘑閽ョ爜鐨勬搷浣滆繃鐨勪簩杩涘埗鏂囦欢锛堣鏄庯細瑙e瘑瀵嗛挜鐮佺瓑浜庡姞瀵嗗瘑閽ョ爜锛夈備綘鍙互缁欎换鎰忎竴涓渶瑕佽В瀵嗙殑鏂囦欢锛岃緭鍏ユ纭殑瑙e瘑瀵嗛挜鐮 + //The decryption key code is set by the user himself at the encrypted file step. This definition, from the encrypted key code of the operation of the binary file (Description: decryption key code is equal to the encryption key code). You can give a random file to be decrypted and enter the correct decryption key code + D_KEY_LENTH_IS_INCORRECT: + int D_KEY_CODE_MAX_LENGTH = 256; + + ConsoleTableColorSet(1, 1, 0); + std::cout << "\n"; + std::cout << "杈撳叆(闀垮害灏忎簬256)瀵嗛挜,涓嶈杈撳叆绌烘牸!" << endl; + std::cout << "Please input >>> the key,Do not enter spaces!\n(length less than 256):" << endl; + cin.getline(D_KEY, 256, '\n').get(); + if(strlen(D_KEY) > D_KEY_CODE_MAX_LENGTH) + { + memset(D_KEY,NULL,sizeof(D_KEY)); //Reset This Variable The Value (NULL = 0) + std :: cout << "瑙e瘑瀵嗛挜鐨勯暱搴︼紝宸茬粡瓒呰繃256浣嶅瓧绗︺ 璇烽噸鏂拌緭鍏ユ墍鏈夎В瀵嗗瘑閽ワ紒" << endl; + std :: cout << "Decryption key length, has more than 256 characters. Please re-enter the all decryption key!" << endl; + system("pause"); + goto D_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(1, 0, 1); + std::cout << "\n"; + std::cout << "杈撳叆(闀垮害灏忎簬256)瀵嗛挜2,涓嶈杈撳叆绌烘牸!" << endl; + std::cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 256):" << endl; + cin.getline(D_KEY2, 256, '\n').get(); + if(strlen(D_KEY2) > D_KEY_CODE_MAX_LENGTH) + { + memset(D_KEY2,NULL,sizeof(D_KEY2)); //Reset This Variable The Value (NULL = 0) + std :: cout << "瑙e瘑瀵嗛挜2鐨勯暱搴︼紝宸茬粡瓒呰繃256浣嶅瓧绗︺ 璇烽噸鏂拌緭鍏ユ墍鏈夎В瀵嗗瘑閽ワ紒" << endl; + std :: cout << "Decryption key2 length, has more than 256 characters. Please re-enter the all decryption key!" << endl; + system("pause"); + goto D_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(1, 0, 0); + std::cout << "\n"; + std::cout << "杈撳叆(闀垮害灏忎簬256)瀵嗛挜3,涓嶈杈撳叆绌烘牸!" << endl; + std::cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 256):" << endl; + cin.getline(D_KEY3, 256, '\n').get(); + if(strlen(D_KEY3) > D_KEY_CODE_MAX_LENGTH) + { + memset(D_KEY3,NULL,sizeof(D_KEY3)); //Reset This Variable The Value (NULL = 0) + std :: cout << "瑙e瘑瀵嗛挜3鐨勯暱搴︼紝宸茬粡瓒呰繃256浣嶅瓧绗︺ 璇烽噸鏂拌緭鍏ユ墍鏈夎В瀵嗗瘑閽ワ紒" << endl; + std :: cout << "Decryption key3 length, has more than 256 characters. Please re-enter the all decryption key!" << endl; + system("pause"); + goto D_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(0, 1, 1); + std::cout << "\n"; + std::cout << "杈撳叆(闀垮害灏忎簬256)瀵嗛挜4,涓嶈杈撳叆绌烘牸!" << endl; + std::cout << "Please input >>> the key4,Do not enter spaces!\n(length less than 256):" << endl; + cin.getline(D_KEY4, 256, '\n').get(); + if(strlen(D_KEY4) > D_KEY_CODE_MAX_LENGTH) + { + memset(D_KEY4,NULL,sizeof(D_KEY4)); //Reset This Variable The Value (NULL = 0) + std :: cout << "瑙e瘑瀵嗛挜4鐨勯暱搴︼紝宸茬粡瓒呰繃256浣嶅瓧绗︺ 璇烽噸鏂拌緭鍏ユ墍鏈夎В瀵嗗瘑閽ワ紒" << endl; + std :: cout << "Decryption key4 length, has more than 256 characters. Please re-enter the all decryption key!" << endl; + system("pause"); + goto D_KEY_LENTH_IS_INCORRECT; + } + + system("cls"); + + ConsoleTableColorSet(0, 1, 0); + + std::cout << "\n"; + std::cout << "濡傛灉鍦ㄥ綋鍓嶆枃浠跺す涓嬮厤缃枃浠禰.\\*.CONFIGFILE]涓嶅瓨鍦紝绋嬪簭灏变笉浼氬府鎮ㄨ嚜鍔ㄦ仮澶嶅師鏉ョ殑鏂囦欢鍚嶇О銆俓n浣犻渶瑕侀噸鏂拌緭鍏ユ枃浠跺悕!" << endl; + std::cout << "If the configuration file [.\\*.CONFIGFILE] does not exist in the current folder, the program will not automatically restore the original file name.\nYou need to re-enter the file name!" << endl; + if (!access(".\\SourceFileMainName.CONFIGFILE", 0)) + { + //char TFMN_Buffer[256]; + ifstream LoadSourceFileNameConfigure(".\\SourceFileMainName.CONFIGFILE", ios::in); + if (LoadSourceFileNameConfigure.fail()) + { + std::cout << "鍔犺浇閰嶇疆鏂囦欢鏃讹紝鍑虹幇浜嗘湭鐭ラ敊璇苟缁撴潫" << endl; + std::cout << "When the configuration file is loaded, an unknown error has occurred and ends" << endl; + } + while (!LoadSourceFileNameConfigure.eof()) + { + LoadSourceFileNameConfigure >> D_TargetFileMainName; + //LoadSourceFileNameConfigure.getline(TFMN_Buffer,256,'\n'); //getline(char *,int,char) 琛ㄧず璇ヨ瀛楃杈惧埌256涓垨閬囧埌鎹㈣灏辩粨鏉 + //D_TargetFileMainName = TFMN_Buffer; + + std::cout << "鎮ㄥ凡鎴愬姛璺宠繃姝ゆ楠" << endl; + std::cout << "You have successfully skipped this step" << endl; + } + LoadSourceFileNameConfigure.close(); + } + else + { + std::cout << "Please output >>> target file main name,not the file extension name!\nDo not enter spaces!\n[TSMY-DECRYPTED]:" << endl; + std::cout << "杈撳嚭鏂囦欢涓昏鍚嶏紝涓嶆槸鏂囦欢鎵╁睍鍚嶏紝涓嶈杈撳叆绌烘牸[-TSMY-DECRYPTED]!" << endl; //缁欒В瀵嗗悗鐨勬枃浠惰緭鍑轰富瑕佹枃浠跺悕锛屽苟淇濆瓨 Output the main file name to the decrypted file and save it + std::cout << "閰嶇疆鏂囦欢" << ".\\SourceFileMainName.CONFIGFILE" << "鏈壘鍒!\n" << "璇烽噸鏂拌緭鍏ュ悕绉!" << endl; + std::cout << "Configuration file" << ".\\SourceFileMainName.CONFIGFILE" << "Not found!\n" << "Please re-enter the name!" << endl; + HANDLE hFILE = CreateFile(".\\SourceFileMainName.CONFIGFILE", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + std::cin >> D_TargetFileMainName; + + } + + system("cls"); + + std::cout << "濡傛灉鍦ㄥ綋鍓嶆枃浠跺す涓嬮厤缃枃浠禰.\\*.CONFIGFILE]涓嶅瓨鍦紝绋嬪簭灏变笉浼氬府鎮ㄨ嚜鍔ㄦ仮澶嶅師鏉ョ殑鏂囦欢鍚嶇О銆俓n浣犻渶瑕侀噸鏂拌緭鍏ユ枃浠跺悕!" << endl; + std::cout << "If the configuration file [.\\*.CONFIGFILE] does not exist in the current folder, the program will not automatically restore the original file name.\nYou need to re-enter the file name!" << endl; + if (!access(".\\SourceFileExtendedName.CONFIGFILE", 0)) + { + ifstream LoadSourceFileNameConfigure(".\\SourceFileExtendedName.CONFIGFILE", ios::in); + //char TFEN_Buffer[256]; + if (LoadSourceFileNameConfigure.fail()) + { + std::cout << "鍔犺浇閰嶇疆鏂囦欢鏃讹紝鍑虹幇浜嗘湭鐭ラ敊璇苟缁撴潫" << endl; + std::cout << "When the configuration file is loaded, an unknown error has occurred and ends" << endl; + } + while (!LoadSourceFileNameConfigure.eof()) + { + LoadSourceFileNameConfigure >> D_TargetFileExtendedName; + //LoadSourceFileNameConfigure.getline(TFEN_Buffer,256,'\n'); //getline(char *,int,char) 琛ㄧず璇ヨ瀛楃杈惧埌256涓垨閬囧埌鎹㈣灏辩粨鏉 + //D_TargetFileExtendedName = TFEN_Buffer; + + std::cout << "鎮ㄥ凡鎴愬姛璺宠繃姝ゆ楠" << endl; + std::cout << "You have successfully skipped this step" << endl; + } + LoadSourceFileNameConfigure.close(); + } + else + { + std::cout << "Please output >>> target file extension name!\nDo not enter spaces!\n[Example: .txt]:" << endl; + std::cout << "杈撳嚭鏂囦欢鎵╁睍鍚嶏紝涓嶈杈撳叆绌烘牸[瀹炰緥锛 .txt]!" << endl; //缁欒В瀵嗗悗鐨勬枃浠惰緭鍑烘枃浠舵墿灞曞悕锛屽苟淇濆瓨 + std::cout << "閰嶇疆鏂囦欢" << ".\\SourceFileExtendedName.CONFIGFILE" << "鏈壘鍒!\n" << "璇烽噸鏂拌緭鍏ュ悕绉!" << endl; + std::cout << "Configuration file" << ".\\SourceFileExtendedName.CONFIGFILE" << "Not found!\n" << "Please re-enter the name!" << endl; + HANDLE hFILE = CreateFile(".\\SourceFileExtendedName.CONFIGFILE", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + std::cin >> D_TargetFileExtendedName; + } + + system("cls"); + + std::cout << "\n"; + std::cout << "濡傛灉鍦ㄥ綋鍓嶆枃浠跺す涓嬮厤缃枃浠禰.\\*.CONFIGFILE]涓嶅瓨鍦紝绋嬪簭灏变笉浼氬府鎮ㄨ嚜鍔ㄦ仮澶嶅師鏉ョ殑鏂囦欢鍚嶇О銆俓n浣犻渶瑕侀噸鏂拌緭鍏ユ枃浠跺悕!" << endl; + std::cout << "If the configuration file [.\\*.CONFIGFILE] does not exist in the current folder, the program will not automatically restore the original file name.\nYou need to re-enter the file name!" << endl; + std::cout << "Please output >>> target file temp add name.\nDo not enter spaces!\n[-DECRYPTED]:" << endl; + std::cout << "杈撳嚭鏂囦欢涓存椂娣诲姞鍚嶏紝涓嶈杈撳叆绌烘牸[-TSMY-DECRYPTED]!" << endl; //缁欒В瀵嗗悗鐨勬枃浠惰緭鍑烘枃浠朵复鏃舵坊鍔犲悕锛屽苟淇濆瓨 + std::cout << "Prevent source encrypted files from being overwritten" << endl; + std::cout << "闃叉婧愬姞瀵嗘枃浠惰瑕嗙洊" << endl; + std::cin >> D_TargetFileTempName; + if (D_TargetFileTempName == " ") + { + string D_TargetFileAddName = "-TSMY-DECRYPTED"; + D_TargetFileTempName = D_TargetFileAddName; + } + + system("cls"); + + string D_SourceFileStringPath = D_IF_PATH + D_SourceFileName; + string D_TargetFileStringPath = D_OF_PATH + D_TargetFileMainName + D_TargetFileTempName + D_TargetFileExtendedName; + + const char *D_SourceFileCharPath = D_SourceFileStringPath.c_str(); + const char *D_TargetFileCharPath = D_TargetFileStringPath.c_str(); + + /*char *D_SourceFileLastNameOutput; //鏈鍚庤鍐欑殑鏂囦欢鍚 + strcpy(D_SourceFileLastNameOutput,D_SourceFileCharPath); + char *D_TargetFileLastNameOutput; //鏈鍚庝复鏃朵繚瀛樼殑瑙e瘑鍚庣殑鏂囦欢鍚 + strcpy(D_TargetFileLastNameOutput,D_TargetFileCharPath);*/ + + ConsoleTableColorSet(0, 0, 1); + std::cout << "Please wait, read and write in the file......" << endl; + std::cout << "璇风瓑寰咃紝鏂囦欢璇诲啓涓......" << endl; + cin.get(); + + if (RunDecryptFile(D_SourceFileCharPath, D_KEY, D_KEY2, D_KEY3, D_KEY4, D_TargetFileCharPath) == 1) + { + printf("鎭枩浣狅紝鏂囦欢[%s]瑙e瘑鎴愬姛锛屼繚瀛樺湪[%s]銆俓n", D_SourceFileCharPath, D_TargetFileCharPath); + printf("Congratulations, the file [%s] is decrypted successfully, saved in [%s]. \n", D_SourceFileCharPath, D_TargetFileCharPath); + cin.get(); + system("pause"); + system("cls"); + goto ProgramMainMenu; + } + } + +/****************************************************************************************************************************************************************/ + + if (Load_User_Keyboard_Input == "3") + { + Instruction_Manual_Language_Restart: + system("cls"); + system("color 1A"); + std::cout << "娆㈣繋浣犵殑鍒版潵锛佽繖鏄湰绋嬪簭鐨勮鏄庢墜鍐孾Beta Version 3.0]锛岃鍔″繀鍦ㄤ娇鐢ㄥ墠锛屼粩缁嗛槄璇" << endl; + std::cout << "Welcome to your arrival! This is the instruction manual [Beta Version 3.0] of this program, please be sure to read carefully before using it" << endl; + std::cout << "" << endl; + std::cout << "enUS----------English 鑻辨枃" << endl; + std::cout << "zhCN----------Chinese 涓枃" << endl; + std::cout << "MENU----------Back Main Menu 杩斿洖涓昏彍鍗" << endl; + std::cout << "" << endl; + std::cout << "Manual:\\Program\\Keyboard_Input> "; + string Instruction_Manual_Language; + std::cin >> Instruction_Manual_Language; + if (Instruction_Manual_Language == "enUS") + { + system("cls"); + system("color 67"); + std::cout << "Manual:\\Program\\Keyboard_Output> " << endl; + std::cout << "" << endl; + std::cout << "When the program executes the function of encrypting the file or decrypting the file, it will create the workspace folder, input the folder, output the folder.\n" << endl; + std::cout << "When the program encrypts the file or decrypts the file and waits, the program is reading and writing the file in the background.\nNever close the program at this time! Otherwise your data is damaged and bear the consequences.\nIt is recommended that you after the data backup, use this program to encrypt the file or decrypt the file!\n" << endl; + system("pause"); + system("cls"); + } + if (Instruction_Manual_Language == "zhCN") + { + system("cls"); + system("color 17"); + std::cout << "Manual:\\Program\\Keyboard_Output> " << endl; + std::cout << "" << endl; + std::cout << "褰撶▼搴忔墽琛屽姞瀵嗘枃浠舵垨瑙e瘑鏂囦欢鐨勫姛鑳芥椂锛屽皢鍒涘缓宸ヤ綔绌洪棿鏂囦欢澶癸紝杈撳叆鏂囦欢澶癸紝杈撳嚭鏂囦欢澶广俓n" << endl; + std::cout << "褰撶▼搴忓姞瀵嗘枃浠舵垨瑙e瘑鏂囦欢骞朵笖绛夊緟鏃讹紝绋嬪簭姝e湪鍚庡彴璇诲彇鍜屽啓鍏ユ枃浠躲傝繖涓椂鍊欙紝姘歌繙涓嶈鍏抽棴杩欎釜绋嬪簭锛乗n鍚﹀垯鎮ㄧ殑鏁版嵁琚崯鍧忓苟鎵挎媴鍚庢灉銆傚缓璁偍鍦ㄨ繘琛屾暟鎹浠戒箣鍚庯紝鐢ㄨ繖涓▼搴忓姞瀵嗘枃浠舵垨瑙e瘑鏂囦欢锛乗n" << endl; + system("pause"); + system("cls"); + + } + if (Instruction_Manual_Language == "MENU","menu") + { + system("cls"); + goto ProgramMainMenu; + } + else + { + if (Instruction_Manual_Language != "enUS", "zhCN") + { + ConsoleTableColorSet(0, 0, 0); + goto Instruction_Manual_Language_Restart; + } + } + + } + +/****************************************************************************************************************************************************************/ + + if (Load_User_Keyboard_Input == "4") + { + Waring_Information: + string You_understand; + system("color 0C"); + std::cout << "[璀﹀憡!]鍗冲皢杩涜鐨勬搷浣滐紝浼氶変腑 鏂囦欢澶癸紝鐒跺悗姘镐箙鐨勫垹闄ゆ墍鏈夋暟鎹!\n" << endl; + std::cout << "鍖呮嫭婧愭枃浠躲佺敓鎴愮殑鍔犲瘑鏂囦欢銆佺敓鎴愮殑瑙e瘑鏂囦欢銆佸瘑鐮佹棩蹇椼侀厤缃甛n" << endl; + std::cout << "濡傛灉浣犵煡閬撻闄╋紝璇锋寜閿洏 [Y閿户缁 N閿繑鍥瀅\n[ Yes / No ]" << endl; + + std::cout << "[Warning!] The upcoming operation will select the and , and then permanently delete all the data!\n" << endl; + std::cout << "Including source files, generated encrypted files, generated decrypted files, password logs, configuration\n" << endl; + std::cout << "If you know the risk, press the keypad [Y key to continue N key to return]\n[Yes / No]" << endl; + std::cin >> You_understand; //浣犱簡瑙i闄╋紵 You understand the risks? + + + if (You_understand == "N") + { + goto ProgramMainMenu; + } + if (You_understand == "n") + { + goto ProgramMainMenu; + } + if (You_understand== "Y") + { + CleanFileFromThisWorkspace(); + + goto ProgramMainMenu; + } + if (You_understand == "y") + { + CleanFileFromThisWorkspace(); + + goto ProgramMainMenu; + } + else + { + goto Waring_Information; + } +} + +/****************************************************************************************************************************************************************/ + + if (Load_User_Keyboard_Input == "5") + { + return 0; + } + else + { + if (Load_User_Keyboard_Input != "1", "2", "3", "4") + { + ConsoleTableColorSet(0, 0, 0); + std::cout << "User Keyboard Input Error !" << endl; + cin.get(); + exit(1); + } + } +} \ No newline at end of file diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/StdAfx.h b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/StdAfx.h index e87646a..00d7f10 100644 --- a/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/StdAfx.h +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Beta-Version3/StdAfx.h @@ -16,7 +16,7 @@ #define DLLEXPORT __declspec(dllexport) #define DLLIMPORT __declspec(dllimport) -#include "stdio.h" +//#include #include #include #include diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/Compile-Test-EODF_3.1.bat b/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/Compile-Test-EODF_3.1.bat new file mode 100644 index 0000000..9271d7e --- /dev/null +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/Compile-Test-EODF_3.1.bat @@ -0,0 +1,22 @@ +@Echo off + +Color 1A + +Cd /d %~dp0 +If Not Exist "..\\..\\..\\Test_Binary\\Alpha-Version3.1\\" ( +Mkdir "..\\..\\..\\Test_Binary\\Alpha-Version3.1\\" +) Else ( +Echo "Info :EODF Test_Binary Folder Already Exist !" +) +Cls +Echo "---------- Code Compile Start ----------" +:: g++.exe -shared -o +:: g++.exe -finput-charset=UTF-8 +:: g++.exe -fexec-charset=GBK +g++.exe -finput-charset=GBK -fexec-charset=GBK -O2 -c ".\\Main_EODF3-1_By_TDOM.cpp" -o "..\\..\\..\\Test_Binary\\Alpha-Version3.1\\CUI_EncryptDecryptFile_TestVersion3-1.objective-binary" +g++.exe -shared "..\\..\\..\\Test_Binary\\Alpha-Version3.1\\CUI_EncryptDecryptFile_TestVersion3-1.objective-binary" -o "..\\..\\..\\Test_Binary\\Alpha-Version3.1\\CUI_EncryptDecryptFile_TestVersion3-1.exe" +g++.exe -static "..\\..\\..\\Test_Binary\\Alpha-Version3.1\\CUI_EncryptDecryptFile_TestVersion3-1.objective-binary" -o "..\\..\\..\\Test_Binary\\Alpha-Version3.1\\CUI_EncryptDecryptFile_TestVersion3-1_StaticLink.exe" +Echo "---------- Code Compile End ----------" +Pause +Cls +Exit diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/EODF3-1_By_TDOM.hpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/EODF3-1_By_TDOM.hpp new file mode 100644 index 0000000..d5653d1 --- /dev/null +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/EODF3-1_By_TDOM.hpp @@ -0,0 +1,906 @@ +int NOIEM; //初始加密模块次数 (Number of initial encryption modules) +int NOIDM; //初始解密模块次数 (Number of initial decryption modules) + +int MAX_NOT_E_MODULE = 12801; //加密模块最大循环次数 (The maximum number of times the encryption module is running) +int MINI_NOT_E_GROUP = 6401; //加密集合最小循环次数 (The minimum number of times the encryption group is running) + +int MAX_NOT_D_MODULE = 12801; //解密模块最大循环次数 (The maximum number of times the decryption module is running) +int MINI_NOT_D_GROUP = 6401; //解密集合最小循环次数 (The minimum number of times the decryption group is running) + +long FileHeaderLength = 0; +long FileHeaderByteData = 0; + + + +/******************************************* +* 加密文件 +* +* E_SourceFileName 需要加密的文件名 +* E_KEY 密钥 +* E_TargetFileNewName 加密完成后要保存的文件名 +* +* @return 加密成功或失败的数字表示 +* +* 0 = 加密失败 +* 1 = 加密成功 +********************************************/ + + int RunEncryptFile(const char *E_SourceFileCharPath, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_KEY4, const char *E_TargetFileCharPath) + { + FILE *FilePointerSource, *FilePointerTarget; //需要打开的文件的指针 Need to open the file pointer + char buffer[1024]; //文件流缓冲区,用于存放从文件读取的数据 File stream buffer, used to store the data read from the file + + int FileByteData, //每次从文件中读取的字节数 The number of bytes read from the file each time + RTNOC, //运行循环次数 (Run The Number Of Cycles) + KeyLength = strlen(E_KEY), //密钥的长度 The length of the key + KeyLength2 = strlen(E_KEY2), + KeyLength3 = strlen(E_KEY3), + KeyLength4 = strlen(E_KEY4); + + FilePointerSource = fopen(E_SourceFileCharPath, "rb"); //以二进制方式读取文件 + if(FilePointerSource == NULL) + { + printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", E_SourceFileCharPath); + printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", E_SourceFileCharPath); + getchar(); + return 0; + } + + FilePointerTarget = fopen(E_TargetFileCharPath, "wb+"); //以二进制方式写入文件 + if(FilePointerTarget == NULL) + { + printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", E_TargetFileCharPath); + printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", E_TargetFileCharPath); + getchar(); + return 0; + } + +/*加密算法开始*/ + +/*****************************************************************************buffer[RTNOC]******************************************************************************/ + +//运行大型加密模块 +//Run large encryption module + +//文件和密钥在缓冲区中计算 +//The file and key are counted in Buffer + + /*Skip file header (512 byte)*/ + fseek(FilePointerSource,512L,SEEK_SET); //Move the file pointer to the 512th byte of the file start + FileHeaderLength = ftell(FilePointerSource);//Get this file header length + fseek(FilePointerSource,0L,SEEK_SET);//Move the file pointer to this file start point + while((FileHeaderByteData = fread(buffer, 1, FileHeaderLength, FilePointerSource)) > 0) //Continuously read fileheaderlength length data from file, save to buffer until end of file + { + fwrite(buffer, 1, FileHeaderByteData, FilePointerTarget); //Write data from buffer to file + } + + /*The pointer to the file stream is moved, and the read and write data continues to start at the 513rd byte*/ + fseek(FilePointerSource,513L,SEEK_SET); + fseek(FilePointerTarget,513L,SEEK_SET); + + + for(NOIEM = 0;NOIEM < MAX_NOT_E_MODULE;NOIEM++) + { + system("@color 6F"); + std::cout << "Please wait, read and write in the file......" << endl; + std::cout << "请等待,文件读写中......" << endl; + system("@color 0D"); + std :: cout << "Encrypting...... Currently in use the first key" << endl; + + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + //Mini-Group Encryption Module Key1-Calculate1 + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] /= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + //Mini-Group Encryption Module Key1-Calculate2 + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + //Mini-Group Encryption Module Key1-Calculate3 + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] *= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + //Mini-Group Encryption Module Key1-Calculate4 + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] -= E_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + +//文件和密钥2在缓冲区中计算 +//The file and key2 are counted in Buffer + + std :: cout << "Encrypting...... Currently in use the second key" << endl; + + //Mini-Group Encryption Module Key2-Calculate1 + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] *= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Encryption Module Key2-Calculate2 + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] -= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Encryption Module Key2-Calculate3 + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] /= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Encryption Module Key2-Calculate4 + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += E_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + +//文件和密钥3在缓冲区中计算 +//The file and key3 are counted in Buffer + + std :: cout << "Encrypting...... Currently in use the third key" << endl; + + //Mini-Group Encryption Module Key3-Calculate1 + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] -= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Encryption Module Key3-Calculate2 + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] /= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Encryption Module Key3-Calculate3 + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Encryption Module Key3-Calculate4 + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] *= E_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + +//文件和密钥4在缓冲区中计算 +//The file and key4 are counted in Buffer + + std :: cout << "Encrypting...... Currently in use the fourth key" << endl; + + //Mini-Group Encryption Module Key4-Calculate1 + + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for (RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] += E_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Encryption Module Key4-Calculate2 + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for (RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] *= E_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Encryption Module Key4-Calculate3 + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for (RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] -= E_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Encryption Module Key4-Calculate4 + for(NOIEM = 0;NOIEM < MINI_NOT_E_GROUP;NOIEM++) + { + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for (RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= E_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递增运算 + { + buffer[RTNOC] /= E_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + if(NOIEM < MAX_NOT_E_MODULE || 12800) + { + break; //End encrypting process + } + + } + +/***********************************************************************************************************************************************************/ + +/*加密算法结束*/ + + fclose(FilePointerSource); + fclose(FilePointerTarget); + + //DeleteFile(E_SourceFileCharPath); + + return 1; + } + +/******************************************* +* 解密文件 +* +* D_SourceFileName 需要解密的文件名 +* D_KEY 密钥 +* D_TargetFileNewName 解密完成后要保存的文件名 +* +* @return 解密成功或失败的数字表示 +* +* 0 = 解密失败 +* 1 = 解密成功 +********************************************/ + + int RunDecryptFile(const char *D_SourceFileCharPath, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_KEY4, const char *D_TargetFileCharPath) + { + FILE *FilePointerSource, *FilePointerTarget; //需要打开的文件的指针 Need to open the file pointer + char buffer[1024]; //文件流缓冲区,用于存放从文件读取的数据 File stream buffer, used to store the data read from the file + + int FileByteData, //每次从文件中读取的字节数 The number of bytes read from the file each time + RTNOC, //运行循环次数 (Run The Number Of Cycles) + KeyLength = strlen(D_KEY), //密钥的长度 The length of the key + KeyLength2 = strlen(D_KEY2), + KeyLength3 = strlen(D_KEY3), + KeyLength4 = strlen(D_KEY4); + + FilePointerSource = fopen(D_SourceFileCharPath, "rb"); //以二进制方式读取文件 + if(FilePointerSource == NULL) + { + printf("File[%s]failed to open, please check whether the file path and name are entered correctly! \n", D_SourceFileCharPath); + printf("文件[%s]打开失败,请检查文件路径和名称是否输入正确!\n", D_SourceFileCharPath); + getchar(); + return 0; + } + + FilePointerTarget = fopen(D_TargetFileCharPath, "wb+"); //以二进制方式写入文件 + if(FilePointerTarget == NULL) + { + printf("File[%s]creation/write failed! Please check whether the file path and name are entered correctly!\n", D_TargetFileCharPath); + printf("文件[%s]创建/写入失败!请检查文件路径和名称是否输入正确!\n", D_TargetFileCharPath); + getchar(); + return 0; + } + +/*解密算法开始*/ + +/***********************************************************************************************************************************************************/ + +//运行大型解密模块 +//Run large decryption module + +//文件和密钥在缓冲区中计算 +//The file and key are counted in Buffer + + /*Skip file header (512 byte)*/ + fseek(FilePointerSource,512L,SEEK_SET); //Move the file pointer to the 512th byte of the file start + FileHeaderLength = ftell(FilePointerSource);//Get this file header length + fseek(FilePointerSource,0L,SEEK_SET);//Move the file pointer to this file start point + while((FileHeaderByteData = fread(buffer, 1, FileHeaderLength, FilePointerSource)) > 0) //Continuously read fileheaderlength length data from file, save to buffer until end of file + { + fwrite(buffer, 1, FileHeaderByteData, FilePointerTarget); //Write data from buffer to file + } + + /*The pointer to the file stream is moved, and the read and write data continues to start at the 513rd byte*/ + fseek(FilePointerSource,513L,SEEK_SET); + fseek(FilePointerTarget,513L,SEEK_SET); + + for(NOIDM = 0;NOIDM < MAX_NOT_D_MODULE;NOIDM++) + { + system("@color 6F"); + std::cout << "Please wait, read and write in the file......" << endl; + std::cout << "请等待,文件读写中......" << endl; + system("@color 0D"); + std :: cout << "Decrypting...... Currently in use the first key" << endl; + + //Mini-Group Decryption Module Key1-Calculate1 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] /= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key1-Calculate2 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key1-Calculate3 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] *= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key1-Calculate4 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] += D_KEY[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + +//文件和密钥2在缓冲区中计算 +//The file and key2 are counted in Buffer + + std :: cout << "Decrypting...... Currently in use the second key" << endl; + + //Mini-Group Decryption Module Key2-Calculate1 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] *= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key2-Calculate2 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] += D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key2-Calculate3 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] /= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key2-Calculate4 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength2, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength2 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= D_KEY2[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + +//文件和密钥3在缓冲区中计算 +//The file and key3 are counted in Buffer + + std :: cout << "Decrypting...... Currently in use the third key" << endl; + + //Mini-Group Decryption Module Key3-Calculate1 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while ((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for (RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] += D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key3-Calculate2 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while ((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for (RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] /= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key3-Calculate3 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while ((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for (RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key3-Calculate4 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while ((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for (RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength3, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength3 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] *= D_KEY3[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + +//文件和密钥4在缓冲区中计算 +//The file and key4 are counted in Buffer + + std :: cout << "Decrypting...... Currently in use the fourth key" << endl; + + //Mini-Group Decryption Module Key4-Calculate1 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] -= D_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key4-Calculate2 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] *= D_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key4-Calculate3 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] += D_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + //Mini-Group Decryption Module Key4-Calculate4 + for(NOIDM = 0;NOIDM < MINI_NOT_D_GROUP;NOIDM++) + { + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行异或运算 + { + buffer[RTNOC] ^= D_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + while((FileByteData = fread(buffer, 1, KeyLength4, FilePointerSource)) > 0) //不断地从文件中读取 KeyLength4 长度的数据,保存到buffer,直到文件结束 + { + for(RTNOC = 0; RTNOC < FileByteData; RTNOC++) //对buffer中的数据逐字节的和E_KEY进行递减运算 + { + buffer[RTNOC] /= D_KEY4[RTNOC]; + } + fwrite(buffer, 1, FileByteData, FilePointerTarget); //将buffer中的数据写入文件 + } + } + + if(NOIEM < MAX_NOT_D_MODULE || 12800) + { + break; //End decrypting process + } + } + +/***********************************************************************************************************************************************************/ + +/*解密算法结束*/ + + fclose(FilePointerSource); + fclose(FilePointerTarget); + + //DeleteFile(D_SourceFileCharPath); + + return 1; + } diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/Main_EODF3-1_By_TDOM.cpp b/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/Main_EODF3-1_By_TDOM.cpp new file mode 100644 index 0000000..db29631 --- /dev/null +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/Main_EODF3-1_By_TDOM.cpp @@ -0,0 +1,744 @@ +/**************************************************************************** +Read Me - About This Source Code File + +Chinese中文: +计算机语言类型: C++ +程序文件名: File_Lock +程序平台类型: Windows 命令行控制台 +程序实际作用: 文件对称式加密解密 +版本: Alpha 3.1 +源代码修改时间: 2018-6-20 +作者: Twilight-Dream-Of-Magic + +English英文: +Computer Language Type: C ++ +Program File Name: File_Lock +Program Platform Type: Windows Command Line Console +The actual role of the program: file symmetric encryption and decryption +Version: Beta 3.1 +Source code modified by: 2018-6-20 +Author: Twilight-Dream-Of-Magic +*****************************************************************************/ + +#include +#include +#include +#include //计算机C语言标准输入输出函数 Computer C language standard input and output functions +#include //计算机C语言标准库函数 Computer C language standard library functions +#include //计算机C语言字符串处理函数 Computer C language string handling functions +#include + +//#include //MakeSureDirectoryPathExists(""); +//#pragma comment(lib, "ImageHlp.lib") + +using namespace std; + +//typedef unsigned char byte; + +int RunEncryptFile(const char *E_SourceFileCharPath, char *E_KEY, char *E_KEY2, char *E_KEY3, char *E_KEY4, const char *E_TargetFileCharPath); +int RunDecryptFile(const char *D_SourceFileCharPath, char *D_KEY, char *D_KEY2, char *D_KEY3, char *D_KEY4, const char *D_TargetFileCharPath); + +/***声明代码-开始 Declare the code - the beginning***/ +//以下变量,应用到文件被加密时 +//The following variables apply when the file is encrypted +string E_IF_PATH = ".\\WorkPath\\Encrypt\\InputFile\\", //加密之前,文件的路径 Before encrypting the path of the file +E_OF_PATH = ".\\WorkPath\\Encrypt\\OutputFile\\"; //加密之后,文件的路径 After encrypting the path of the file + +string E_SourceFileName, // 源文件名 +E_SourceFileMainName, // 源文件主要名 +E_SourceFileExtendedName, // 源文件扩展名 +E_TargetFileExtendedName; // 目标文件扩展名 + +char E_KEY[256], //File (Encryption or Encrypted) key 文件加密密钥 +E_KEY2[256], +E_KEY3[256], +E_KEY4[256]; +/***声明代码-结束 Declare the code - end***/ + +/***声明代码-开始 Declare the code - the beginning***/ +//以下变量,应用到文件被解密时 +//The following variables apply when the file is decrypted +string D_IF_PATH = ".\\WorkPath\\Decrypt\\InputFile\\", //解密之前,文件的路径 Before decrypting the path of the file +D_OF_PATH = ".\\WorkPath\\Decrypt\\OutputFile\\"; //解密之后,文件的路径 After decrypting the path of the file + +string D_SourceFileName, //源文件名 +D_TargetFileMainName, //目标文件主要名 +D_TargetFileTempName, //目标文件临时添加名 +D_TargetFileExtendedName; //目标文件源扩展名 + +char D_KEY[256], //File (Decryption or Decrypted) key 文件解密密钥 +D_KEY2[256], +D_KEY3[256], +D_KEY4[256]; +/***声明代码-结束 Declare the code - end***/ + +/****************************************************************************************************************************************************************/ + +void ConsoleTableColorSet(int R, int G, int B) +{ + if (R < 0) R = 0; + if (R > 1) R = 1; + + if (G < 0) G = 0; + if (G > 1) G = 1; + + if (B < 0) B = 0; + if (B > 1) B = 1; + + if (R == 1 && G == 1 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + } + else if (R == 1 && G == 1 && B == 0) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); + } + else if (R == 1 && G == 0 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE); + } + else if (R == 0 && G == 1 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE); + } + else if (R == 1 && G == 0 && B == 0) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED); + } + else if (R == 0 && G == 1 && B == 0) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN); + } + else if (R == 0 && G == 0 && B == 1) + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE); + } + else + { + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY); + } +} + +void CleanFileFromThisWorkspace() +{ + DeleteFile(".\\SourceFileName.CONFIGFILE"); + DeleteFile(".\\SourceFileMainName.CONFIGFILE"); + DeleteFile(".\\SourceFileExtendedName.CONFIGFILE"); + + system("@Del /s /f /q .\\File-Key-Record-Log\\*.*"); + system("@Del /s /f /q .\\WorkPath\\*.*"); + + system("@Del /s /f /q .\\WorkPath\\Encrypt\\*.*"); + system("@Del /s /f /q .\\WorkPath\\Encrypt\\InputFile\\*.*"); + system("@Del /s /f /q .\\WorkPath\\Encrypt\\OutputFile\\*.*"); + + system("@Del /s /f /q .\\WorkPath\\Decrypt\\*.*"); + system("@Del /s /f /q .\\WorkPath\\Decrypt\\InputFile\\*.*"); + system("@Del /s /f /q .\\WorkPath\\Decrypt\\OutputFile\\*.*"); + + system("@Rmdir /s /q .\\File-Key-Record-Log\\"); + + system("@Rmdir /s /q .\\WorkPath\\Encrypt\\OutputFile\\"); + system("@Rmdir /s /q .\\WorkPath\\Encrypt\\InputFile\\"); + system("@Rmdir /s /q .\\WorkPath\\Encrypt\\"); + + system("@Rmdir /s /q .\\WorkPath\\Decrypt\\OutputFile\\"); + system("@Rmdir /s /q .\\WorkPath\\Decrypt\\InputFile\\"); + system("@Rmdir /s /q .\\WorkPath\\Decrypt\\"); + system("@Rmdir /s /q .\\WorkPath\\"); + + system("cls"); +} + +int main() +{ + ProgramMainMenu: + + string Load_User_Keyboard_Input; + + system("color 0A"); + system("cls"); + + std::cout << "----------------------------------------" << endl; + std::cout << "Enter 1 Encrypt File" << endl; + std::cout << "1.加密文件\n" << endl; + std::cout << "Enter 2 Decrypt File" << endl; + std::cout << "2.解密文件\n" << endl; + std::cout << "Enter 3 Use The Information Manual" << endl; + std::cout << "3.使用信息说明手册\n" << endl; + std::cout << "Enter 4 Clean Up The Workspace[To Restore The Initial State]" << endl; + std::cout << "4.清理工作空间[恢复初始状态]\n" << endl; + std::cout << "Enter 5 Exit Program" << endl; + std::cout << "5.退出程序\n" << endl; + std::cout << "----------------------------------------" << endl; + std::cout << "System:Input And Output/Enter>"; + + std::cin >> Load_User_Keyboard_Input; + getchar(); + +/****************************************************************************************************************************************************************/ + + if (Load_User_Keyboard_Input == "1") + { + if (!access(".\\WorkPath\\Encrypt\\InputFile\\", 0)) + { + std::cout << "Building and Loading Folder 20%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Encrypt\\InputFile\\"); + } + + if (!access(".\\WorkPath\\Encrypt\\OutputFile\\", 0)) + { + std::cout << "Building and Loading Folder 40%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Encrypt\\OutputFile\\"); + } + + if (!access(".\\WorkPath\\Decrypt\\InputFile\\", 0)) + { + std::cout << "Building and Loading Folder 60%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Decrypt\\InputFile\\"); + } + + if (!access(".\\WorkPath\\Decrypt\\OutputFile\\", 0)) + { + std::cout << "Building and Loading Folder 80%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Decrypt\\OutputFile\\"); + } + + if (!access(".\\File-Key-Record-Log\\", 0)) + { + std::cout << "Building and Loading Folder 100%" << endl; + } + else + { + system("@Mkdir .\\File-Key-Record-Log\\"); + } + + system("cls"); + system("color 1A"); + + ConsoleTableColorSet(0, 0, 0); + std::cout << "Please input >>> the source file name + file extension name.\nDo not enter spaces!\n:" << endl; + std::cout << "输入要加密的文件名+文件扩展名,不要输入空格!" << endl; + std::cin >> E_SourceFileName; + + std::cout << "Please input >>> the source file name, not the file extension name!\nDo not enter spaces!\n:" << endl; + std::cout << "输入要加密的文件主要名,不是文件扩展名!不要输入空格!" << endl; + std::cin >> E_SourceFileMainName; + + std::cout << "Please input >>> the file extension name.\nDo not enter spaces!\n:" << endl; + std::cout << "输入要加密的文件扩展名,不要输入空格!" << endl; + std::cin >> E_SourceFileExtendedName; + system("cls"); + + std::cout << "正在记录并导出,源文件名称......\n[警告!]在进行本次操作后,请下次选择同样名称的加密文件,进行解密文件操作!\n否则,在那之前,请立即禁止使用加密文件功能!" << endl; + std::cout << "Recording and exporting, source file name......\n[Warning!]After doing this operation, please select the same name next time the encrypted file, decrypt the file operation!\nOtherwise, before that, please immediately disable the use of encrypted file function" << endl; + std::cout << "您是否接受这个协议?[键盘Enter继续] 或者 [关闭程序]......" << endl; + std::cout << "Whether you accept this agreement?[Keyboard Enter Continue] Or [Close this program]......" << endl; + + system("pause"); + system("cls"); + + ofstream SourceFileNameTemporarySave; + + SourceFileNameTemporarySave.open(".\\SourceFileName.CONFIGFILE"); + SourceFileNameTemporarySave << E_SourceFileName << endl; + SourceFileNameTemporarySave.close(); + + SourceFileNameTemporarySave.open(".\\SourceFileMainName.CONFIGFILE"); + SourceFileNameTemporarySave << E_SourceFileMainName << endl; + SourceFileNameTemporarySave.close(); + + SourceFileNameTemporarySave.open(".\\SourceFileExtendedName.CONFIGFILE"); + SourceFileNameTemporarySave << E_SourceFileExtendedName << endl; + SourceFileNameTemporarySave.close(); + + //加密密钥码是用户自己定义的,(长度小于256)。可以任意的给一个需要加密的文件添加一个或多个加密密钥码 + //Encryption key code is user-defined, (length less than 256). You can optionally add one or more encryption keys to the one files you want to encrypt + E_KEY_LENTH_IS_INCORRECT: + int E_KEY_CODE_MAX_LENGTH = 256; + + ConsoleTableColorSet(0, 0, 1); + std::cout << "\n"; + std::cout << "输入(长度小于256)密钥,不要输入空格!" << endl; + std::cout << "Please input >>> the key,Do not enter spaces!\n(length less than 256):" << endl; + std::cin >> E_KEY; + if(strlen(E_KEY) > E_KEY_CODE_MAX_LENGTH) + { + memset(E_KEY,NULL,sizeof(E_KEY)); //Reset This Variable The Value (NULL = 0) + std :: cout << "加密密钥的长度,已经超过256位字符。 请重新输入所有加密密钥!" << endl; + std :: cout << "Encryption key length, has more than 256 characters. Please re-enter the all encryption key!" << endl; + system("pause"); + goto E_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(0, 1, 0); + std::cout << "\n"; + std::cout << "输入(长度小于256)密钥2,不要输入空格!" << endl; + std::cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 256):" << endl; + std::cin >> E_KEY2; + if(strlen(E_KEY2) > E_KEY_CODE_MAX_LENGTH) + { + memset(E_KEY2,NULL,sizeof(E_KEY2)); //Reset This Variable The Value (NULL = 0) + std :: cout << "加密密钥2的长度,已经超过256位字符。 请重新输入所有加密密钥!" << endl; + std :: cout << "Encryption key2 length, has more than 256 characters. Please re-enter the all encryption key!" << endl; + system("pause"); + goto E_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(0, 1, 1); + std::cout << "\n"; + std::cout << "输入(长度小于256)密钥3,不要输入空格!" << endl; + std::cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 256):" << endl; + std::cin >> E_KEY3; + if(strlen(E_KEY3) > E_KEY_CODE_MAX_LENGTH) + { + memset(E_KEY3,NULL,sizeof(E_KEY3)); //Reset This Variable The Value (NULL = 0) + std :: cout << "加密密钥3的长度,已经超过256位字符。 请重新输入所有加密密钥!" << endl; + std :: cout << "Encryption key3 length, has more than 256 characters. Please re-enter the all encryption key!" << endl; + system("pause"); + goto E_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(1, 0, 0); + std::cout << "\n"; + std::cout << "输入(长度小于256)密钥4,不要输入空格!" << endl; + std::cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 256):" << endl; + std::cin >> E_KEY4; + if(strlen(E_KEY4) > E_KEY_CODE_MAX_LENGTH) + { + memset(E_KEY4,NULL,sizeof(E_KEY4)); //Reset This Variable The Value (NULL = 0) + std :: cout << "加密密钥4的长度,已经超过256位字符。 请重新输入所有加密密钥!" << endl; + std :: cout << "Encryption key4 length, has more than 256 characters. Please re-enter the all encryption key!" << endl; + system("pause"); + goto E_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(1, 0, 1); + std::cout << "\n"; + std::cout << "Please output >>> file extension name.\nDo not enter spaces!\n[.TSMY-ENCRYPTED]:" << endl; + std::cout << "输出文件扩展名,不要输入空格[.TSMY-ENCRYPTED]:" << endl; //给加密后的文件输出文件扩展名,并保存 Export the file extension to the encrypted file and save it + std::cin >> E_TargetFileExtendedName; + if (E_TargetFileExtendedName == " ") + { + string E_TargetFileAddExtendedName = ".TSMY-ENCRYPTED"; + E_TargetFileExtendedName = E_TargetFileAddExtendedName; + } + + system("cls"); + + string E_SourceFileStringPath = E_IF_PATH + E_SourceFileName; + string E_TargetFileStringPath = E_OF_PATH + E_SourceFileName + E_TargetFileExtendedName; + + const char *E_SourceFileCharPath = E_SourceFileStringPath.c_str(); + const char *E_TargetFileCharPath = E_TargetFileStringPath.c_str(); + + /*char *E_SourceFileLastNameOutput; //最后读写的文件名 + strcpy(E_SourceFileLastNameOutput,E_SourceFileCharPath); + char *E_TargetFileLastNameOutput; //最后保存的加密后文件名 + strcpy(E_TargetFileLastNameOutput,E_TargetFileCharPath);*/ + + ConsoleTableColorSet(1, 1, 0); + std::cout << "正在记录并导出,本次用于文件加密,4个密钥字符串......" << endl; + std::cout << "Is being recorded and exported, this time for file encryption, 4 key string......" << endl; + + ofstream KeyStringSaveToFile; + + KeyStringSaveToFile.open(".\\File-Key-Record-Log\\ENCRYPTION-DECRYPTION-PASSWORD.KEY.TXT"); + + KeyStringSaveToFile << "Twilight-Dream-Of-Magic File Lock Password [Key String] Save\n" << endl; + KeyStringSaveToFile << "\n" << endl; + KeyStringSaveToFile << "Source Input File Name and Path: " << E_SourceFileStringPath << "\n" << endl; + KeyStringSaveToFile << "EncryptFile: New Output Target File Name and Path: " << E_TargetFileStringPath << "\n" << endl; + KeyStringSaveToFile << "Key string1 [Password1]: " << E_KEY << "\n" << endl; + KeyStringSaveToFile << "Key string2 [Password2]: " << E_KEY2 << "\n" << endl; + KeyStringSaveToFile << "Key string3 [Password3]: " << E_KEY3 << "\n" << endl; + KeyStringSaveToFile << "Key string4 [Password4]: " << E_KEY4 << "\n" << endl; + KeyStringSaveToFile << "<******************************************************************************************>" << "\n" << endl; + + KeyStringSaveToFile.close(); + + ConsoleTableColorSet(1, 1, 1); + std::cout << "Please wait, read and write in the file......" << endl; + std::cout << "请等待,文件读写中......" << endl; + getchar(); + + if (RunEncryptFile(E_SourceFileCharPath, E_KEY, E_KEY2, E_KEY3, E_KEY4, E_TargetFileCharPath)) + { + printf("恭喜你,文件[%s]加密成功,保存在[%s]。\n", E_SourceFileCharPath, E_TargetFileCharPath); + printf("Congratulations, the file [%s] is encrypted successfully, saved in [%s]. \n", E_SourceFileCharPath, E_TargetFileCharPath); + getchar(); + system("pause"); + system("cls"); + goto ProgramMainMenu; + } + } + +/****************************************************************************************************************************************************************/ + + if (Load_User_Keyboard_Input == "2") + { + if (!access(".\\WorkPath\\Encrypt\\InputFile\\", 0)) + { + std::cout << "Building and Loading Folder 20%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Encrypt\\InputFile\\"); + } + + if (!access(".\\WorkPath\\Encrypt\\OutputFile\\", 0)) + { + std::cout << "Building and Loading Folder 40%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Encrypt\\OutputFile\\"); + } + + if (!access(".\\WorkPath\\Decrypt\\InputFile\\", 0)) + { + std::cout << "Building and Loading Folder 60%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Decrypt\\InputFile\\"); + } + + if (!access(".\\WorkPath\\Decrypt\\OutputFile\\", 0)) + { + std::cout << "Building and Loading Folder 80%" << endl; + } + else + { + system("@Mkdir .\\WorkPath\\Decrypt\\OutputFile\\"); + } + + if (!access(".\\File-Key-Record-Log\\", 0)) + { + std::cout << "Building and Loading Folder 100%" << endl; + } + else + { + system("@Mkdir .\\File-Key-Record-Log\\"); + } + + system("cls"); + system("color 1A"); + + ConsoleTableColorSet(1, 1, 1); + std::cout << "Please input >>> the source file name + file extension name.\nDo not enter spaces!\n:" << endl; + std::cout << "输入要解密的文件名+文件扩展名,不要输入空格!" << endl; + std::cin >> D_SourceFileName; + + //解密密钥码是由用户自己在加密文件步骤设置的。这个定义,来自被加密密钥码的操作过的二进制文件(说明:解密密钥码等于加密密钥码)。你可以给任意一个需要解密的文件,输入正确的解密密钥码 + //The decryption key code is set by the user himself at the encrypted file step. This definition, from the encrypted key code of the operation of the binary file (Description: decryption key code is equal to the encryption key code). You can give a random file to be decrypted and enter the correct decryption key code + D_KEY_LENTH_IS_INCORRECT: + int D_KEY_CODE_MAX_LENGTH = 256; + + ConsoleTableColorSet(1, 1, 0); + std::cout << "\n"; + std::cout << "输入(长度小于256)密钥,不要输入空格!" << endl; + std::cout << "Please input >>> the key3,Do not enter spaces!\n(length less than 256):" << endl; + std::cin >> D_KEY; + if(strlen(D_KEY) > D_KEY_CODE_MAX_LENGTH) + { + memset(D_KEY,NULL,sizeof(D_KEY)); //Reset This Variable The Value (NULL = 0) + std :: cout << "解密密钥的长度,已经超过256位字符。 请重新输入所有解密密钥!" << endl; + std :: cout << "Decryption key length, has more than 256 characters. Please re-enter the all decryption key!" << endl; + system("pause"); + goto D_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(1, 0, 1); + std::cout << "\n"; + std::cout << "输入(长度小于256)密钥2,不要输入空格!" << endl; + std::cout << "Please input >>> the key2,Do not enter spaces!\n(length less than 256):" << endl; + std::cin >> D_KEY2; + if(strlen(D_KEY2) > D_KEY_CODE_MAX_LENGTH) + { + memset(D_KEY2,NULL,sizeof(D_KEY2)); //Reset This Variable The Value (NULL = 0) + std :: cout << "解密密钥2的长度,已经超过256位字符。 请重新输入所有解密密钥!" << endl; + std :: cout << "Decryption key2 length, has more than 256 characters. Please re-enter the all decryption key!" << endl; + system("pause"); + goto D_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(1, 0, 0); + std::cout << "\n"; + std::cout << "输入(长度小于256)密钥3,不要输入空格!" << endl; + std::cout << "Please input >>> the key,Do not enter spaces!\n(length less than 256):" << endl; + std::cin >> D_KEY3; + if(strlen(D_KEY3) > D_KEY_CODE_MAX_LENGTH) + { + memset(D_KEY3,NULL,sizeof(D_KEY3)); //Reset This Variable The Value (NULL = 0) + std :: cout << "解密密钥3的长度,已经超过256位字符。 请重新输入所有解密密钥!" << endl; + std :: cout << "Decryption key3 length, has more than 256 characters. Please re-enter the all decryption key!" << endl; + system("pause"); + goto D_KEY_LENTH_IS_INCORRECT; + } + + ConsoleTableColorSet(0, 1, 1); + std::cout << "\n"; + std::cout << "输入(长度小于256)密钥4,不要输入空格!" << endl; + std::cout << "Please input >>> the key,Do not enter spaces!\n(length less than 256):" << endl; + std::cin >> D_KEY4; + if(strlen(D_KEY4) > D_KEY_CODE_MAX_LENGTH) + { + memset(D_KEY4,NULL,sizeof(D_KEY4)); //Reset This Variable The Value (NULL = 0) + std :: cout << "解密密钥4的长度,已经超过256位字符。 请重新输入所有解密密钥!" << endl; + std :: cout << "Decryption key4 length, has more than 256 characters. Please re-enter the all decryption key!" << endl; + system("pause"); + goto D_KEY_LENTH_IS_INCORRECT; + } + + system("cls"); + + ConsoleTableColorSet(0, 1, 0); + + std::cout << "\n"; + std::cout << "如果在当前文件夹下配置文件[.\\*.CONFIGFILE]不存在,程序就不会帮您自动恢复原来的文件名称。\n你需要重新输入文件名!" << endl; + std::cout << "If the configuration file [.\\*.CONFIGFILE] does not exist in the current folder, the program will not automatically restore the original file name.\nYou need to re-enter the file name!" << endl; + std::cout << "Please output >>> target file main name,not the file extension name!\nDo not enter spaces!\n[DATA-DECRYPTED]:" << endl; + std::cout << "输出文件主要名,不是文件扩展名,不要输入空格[DATA-TSMY-DECRYPTED]!" << endl; //给解密后的文件输出主要文件名,并保存 Output the main file name to the decrypted file and save it + if (!access(".\\SourceFileMainName.CONFIGFILE", 0)) + { + //char TFMN_Buffer[256]; + ifstream LoadSourceFileNameConfigure(".\\SourceFileMainName.CONFIGFILE", ios::in); + if (LoadSourceFileNameConfigure.fail()) + { + std::cout << "加载配置文件时,出现了未知错误并结束" << endl; + std::cout << "When the configuration file is loaded, an unknown error has occurred and ends" << endl; + system("pause"); + return 0; + } + while (!LoadSourceFileNameConfigure.eof()) + { + LoadSourceFileNameConfigure >> D_TargetFileMainName; + //LoadSourceFileNameConfigure.getline(TFMN_Buffer,256,'\n'); //getline(char *,int,char) 表示该行字符达到256个或遇到换行就结束 + //D_TargetFileMainName = TFMN_Buffer; + + std::cout << "您已成功跳过此步骤" << endl; + std::cout << "You have successfully skipped this step" << endl; + } + LoadSourceFileNameConfigure.close(); + } + else + { + std::cout << "配置文件" << ".\\SourceFileMainName.CONFIGFILE" << "未找到!\n" << "请重新输入名称!" << endl; + std::cout << "Configuration file" << ".\\SourceFileMainName.CONFIGFILE " << "Not found!\n" << "Please re-enter the name!" << endl; + HANDLE hFILE = CreateFile(".\\SourceFileMainName.CONFIGFILE", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + std::cin >> D_TargetFileMainName; + + } + + system("cls"); + + std::cout << "如果在当前文件夹下配置文件[.\\*.CONFIGFILE]不存在,程序就不会帮您自动恢复原来的文件名称。\n你需要重新输入文件名!" << endl; + std::cout << "If the configuration file [.\\*.CONFIGFILE] does not exist in the current folder, the program will not automatically restore the original file name.\nYou need to re-enter the file name!" << endl; + std::cout << "Please output >>> target file extension name!\nDo not enter spaces!\n[Example: .txt]:" << endl; + std::cout << "输出文件扩展名,不要输入空格[实例: .txt]!" << endl; //给解密后的文件输出文件扩展名,并保存 + if (!access(".\\SourceFileExtendedName.CONFIGFILE", 0)) + { + ifstream LoadSourceFileNameConfigure(".\\SourceFileExtendedName.CONFIGFILE", ios::in); + //char TFEN_Buffer[256]; + if (LoadSourceFileNameConfigure.fail()) + { + std::cout << "加载配置文件时,出现了未知错误并结束" << endl; + std::cout << "When the configuration file is loaded, an unknown error has occurred and ends" << endl; + system("pause"); + return 0; + } + while (!LoadSourceFileNameConfigure.eof()) + { + LoadSourceFileNameConfigure >> D_TargetFileExtendedName; + //LoadSourceFileNameConfigure.getline(TFEN_Buffer,256,'\n'); //getline(char *,int,char) 表示该行字符达到256个或遇到换行就结束 + //D_TargetFileExtendedName = TFEN_Buffer; + + std::cout << "您已成功跳过此步骤" << endl; + std::cout << "You have successfully skipped this step" << endl; + } + LoadSourceFileNameConfigure.close(); + } + else + { + std::cout << "配置文件" << ".\\SourceFileExtendedName.CONFIGFILE" << "未找到!\n" << "请重新输入名称!" << endl; + std::cout << "Configuration file" << ".\\SourceFileExtendedName.CONFIGFILE " << "Not found!\n" << "Please re-enter the name!" << endl; + HANDLE hFILE = CreateFile(".\\SourceFileExtendedName.CONFIGFILE", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + std::cin >> D_TargetFileExtendedName; + } + + system("cls"); + + std::cout << "\n"; + std::cout << "如果在当前文件夹下配置文件[.\\*.CONFIGFILE]不存在,程序就不会帮您自动恢复原来的文件名称。\n你需要重新输入文件名!" << endl; + std::cout << "If the configuration file [.\\*.CONFIGFILE] does not exist in the current folder, the program will not automatically restore the original file name.\nYou need to re-enter the file name!" << endl; + std::cout << "Please output >>> target file temporary add name.\nDo not enter spaces!\n[-DECRYPTED]:" << endl; + std::cout << "输出文件临时添加名,不要输入空格[-TSMY-DECRYPTED]!" << endl; //给解密后的文件输出文件临时添加名,并保存 + std::cout << "Prevent source encrypted files from being overwritten" << endl; + std::cout << "防止源加密文件被覆盖" << endl; + std::cin >> D_TargetFileTempName; + if (D_TargetFileTempName == " ") + { + string D_TargetFileAddName = "-TSMY-DECRYPTED"; + D_TargetFileTempName = D_TargetFileAddName; + } + + system("cls"); + + string D_SourceFileStringPath = D_IF_PATH + D_SourceFileName; + string D_TargetFileStringPath = D_OF_PATH + D_TargetFileMainName + D_TargetFileTempName + D_TargetFileExtendedName; + + const char *D_SourceFileCharPath = D_SourceFileStringPath.c_str(); + const char *D_TargetFileCharPath = D_TargetFileStringPath.c_str(); + + /*char *D_SourceFileLastNameOutput; //最后读写的文件名 + strcpy(D_SourceFileLastNameOutput,D_SourceFileCharPath); + char *D_TargetFileLastNameOutput; //最后临时保存的解密后的文件名 + strcpy(D_TargetFileLastNameOutput,D_TargetFileCharPath);*/ + + ConsoleTableColorSet(0, 0, 1); + std::cout << "Please wait, read and write in the file......" << endl; + std::cout << "请等待,文件读写中......" << endl; + getchar(); + + if (RunDecryptFile(D_SourceFileCharPath, D_KEY, D_KEY2, D_KEY3, D_KEY4, D_TargetFileCharPath)) + { + printf("恭喜你,文件[%s]解密成功,保存在[%s]。\n", D_SourceFileCharPath, D_TargetFileCharPath); + printf("Congratulations, the file [%s] is decrypted successfully, saved in [%s]. \n", D_SourceFileCharPath, D_TargetFileCharPath); + getchar(); + system("pause"); + system("cls"); + goto ProgramMainMenu; + } + } + +/****************************************************************************************************************************************************************/ + + if (Load_User_Keyboard_Input == "3") + { + Instruction_Manual_Language_Restart: + system("cls"); + system("color 1A"); + std::cout << "欢迎你的到来!这是本程序的说明手册[Beta Version 3.1],请务必在使用前,仔细阅读" << endl; + std::cout << "Welcome to your arrival! This is the instruction manual [Beta Version 3.1] of this program, please be sure to read carefully before using it" << endl; + std::cout << "" << endl; + std::cout << "enUS----------English 英文" << endl; + std::cout << "zhCN----------Chinese 中文" << endl; + std::cout << "MENU----------Back Main Menu 返回主菜单" << endl; + std::cout << "" << endl; + std::cout << "Manual:\\Program\\Keyboard_Input> "; + string Instruction_Manual_Language; + std::cin >> Instruction_Manual_Language; + if (Instruction_Manual_Language == "enUS") + { + system("cls"); + system("color 67"); + std::cout << "Manual:\\Program\\Keyboard_Output> " << endl; + std::cout << "" << endl; + std::cout << "When the program executes the function of encrypting the file or decrypting the file, it will create the workspace folder, input the folder, output the folder.\n" << endl; + std::cout << "When the program encrypts the file or decrypts the file and waits, the program is reading and writing the file in the background.\nNever close the program at this time! Otherwise your data is damaged and bear the consequences.\nIt is recommended that you after the data backup, use this program to encrypt the file or decrypt the file!\n" << endl; + system("pause"); + system("cls"); + } + if (Instruction_Manual_Language == "zhCN") + { + system("cls"); + system("color 17"); + std::cout << "Manual:\\Program\\Keyboard_Output> " << endl; + std::cout << "" << endl; + std::cout << "当程序执行加密文件或解密文件的功能时,将创建工作空间文件夹,输入文件夹,输出文件夹。\n" << endl; + std::cout << "当程序加密文件或解密文件并且等待时,程序正在后台读取和写入文件。这个时候,永远不要关闭这个程序!\n否则您的数据被损坏并承担后果。建议您在进行数据备份之后,用这个程序加密文件或解密文件!\n" << endl; + system("pause"); + system("cls"); + + } + if (Instruction_Manual_Language == "MENU","menu") + { + system("cls"); + goto ProgramMainMenu; + } + else + { + if (Instruction_Manual_Language != "enUS", "zhCN") + { + ConsoleTableColorSet(0, 0, 0); + goto Instruction_Manual_Language_Restart; + } + } + + } + +/****************************************************************************************************************************************************************/ + + if (Load_User_Keyboard_Input == "4") + { + Waring_Information: + string You_understand; + system("color 0C"); + std::cout << "[警告!]即将进行的操作,会选中 文件夹,然后永久的删除所有数据!\n" << endl; + std::cout << "包括源文件、生成的加密文件、生成的解密文件、密码日志、配置\n" << endl; + std::cout << "如果你知道风险,请按键盘 [Y键继续 N键返回]\n[ Yes / No ]" << endl; + + std::cout << "[Warning!] The upcoming operation will select the and , and then permanently delete all the data!\n" << endl; + std::cout << "Including source files, generated encrypted files, generated decrypted files, password logs, configuration\n" << endl; + std::cout << "If you know the risk, press the keypad [Y key to continue N key to return]\n[Yes / No]" << endl; + std::cin >> You_understand; //你了解风险? You understand the risks? + + + if (You_understand == "N") + { + goto ProgramMainMenu; + } + if (You_understand == "n") + { + goto ProgramMainMenu; + } + if (You_understand== "Y") + { + CleanFileFromThisWorkspace(); + + goto ProgramMainMenu; + } + if (You_understand == "y") + { + CleanFileFromThisWorkspace(); + + goto ProgramMainMenu; + } + else + { + goto Waring_Information; + } + } + +/****************************************************************************************************************************************************************/ + + if (Load_User_Keyboard_Input == "5") + { + return 0; + } + else + { + if (Load_User_Keyboard_Input != "1", "2", "3", "4") + { + ConsoleTableColorSet(0, 0, 0); + std::cout << "User Keyboard Input Error !" << endl; + getchar(); + exit(1); + } + } +} + +#include "EODF3-1_By_TDOM.hpp" diff --git a/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/StdAfx.h b/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/StdAfx.h new file mode 100644 index 0000000..4a854f1 --- /dev/null +++ b/[Encrypt_Or_Decrypt_File]-Source-Code/Test-Version/Alpha-Version3.1/StdAfx.h @@ -0,0 +1,32 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__4607A810_33E2_483D_80D8_BE41F0D473D5__INCLUDED_) +#define AFX_STDAFX_H__4607A810_33E2_483D_80D8_BE41F0D473D5__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +// Insert your headers here +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define DLLEXPORT __declspec(dllexport) +#define DLLIMPORT __declspec(dllimport) + +//#include +#include +#include +#include + +#pragma comment(lib,"ws2_32.lib") + +// TODO: reference additional headers your program requires here +void Msg(char *szFormat, ...); +void dbMsg(char *szFormat, ...); +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__4607A810_33E2_483D_80D8_BE41F0D473D5__INCLUDED_)