commit 1a012f519bd6dc08279b83ebf45c73257ddb9c91 Author: David Vereb Date: Fri Mar 29 16:59:38 2019 -0400 Initial commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c7cc22b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +a.out +*~ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b31e207 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +a.out: main.cpp + clang++ -std=c++11 -g main.cpp -lncurses diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..dd95d55 --- /dev/null +++ b/main.cpp @@ -0,0 +1,72 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + initscr(); + + if(argc != 2) + { + printw("You must supply a filename as the only parameter."); + refresh(); + getch(); + endwin(); + return 1; + } + + std::string param = std::string(argv[1]); + if(param == "--help" || param == "-h") + { + printw("Supply the filename as the only parameter.\n"); + printw("At the end of the file you will be prompted for a fake password.\n"); + printw("Pressing enter at this point closes the program.\n"); + refresh(); + getch(); + endwin(); + return 0; + } + + std::ifstream ifs(argv[1]); + if(!ifs.is_open()) + { + printw("Permission Denied."); + refresh(); + getch(); + endwin(); + return 2; + } + + noecho(); + cbreak(); + + printw("New file, \""); + printw(argv[1]); + printw("\".\n"); + printw("\n"); + refresh(); + getch(); + + char c = ' '; + while((c = ifs.get()) && !ifs.eof()) + { + addch( c); + refresh(); + getch(); + } + + printw("\n"); + printw("\n"); + + printw("Please enter your password to encrypt this file.\n"); + printw(" password: "); + + while((c = getch())) + { + if(c == '\n') + break; + } + + endwin(); + return 0; +}