Initial commit.

This commit is contained in:
David Vereb 2019-03-29 16:59:38 -04:00
commit 1a012f519b
3 changed files with 76 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
a.out
*~

2
Makefile Normal file
View File

@ -0,0 +1,2 @@
a.out: main.cpp
clang++ -std=c++11 -g main.cpp -lncurses

72
main.cpp Normal file
View File

@ -0,0 +1,72 @@
#include <ncurses.h>
#include <string>
#include <fstream>
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;
}