2019-03-29 16:59:38 -04:00
|
|
|
#include <ncurses.h>
|
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
initscr();
|
|
|
|
|
2019-03-29 19:35:22 -04:00
|
|
|
std::string param = "-h"; // default to usage
|
|
|
|
if(argc == 2)
|
|
|
|
param = std::string(argv[1]);
|
2019-03-29 16:59:38 -04:00
|
|
|
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())
|
|
|
|
{
|
2019-03-29 19:35:22 -04:00
|
|
|
printw("ERROR: File \"%s\" Not Found.", param.c_str());
|
2019-03-29 16:59:38 -04:00
|
|
|
refresh();
|
|
|
|
getch();
|
|
|
|
endwin();
|
2019-03-29 19:35:22 -04:00
|
|
|
return 1;
|
2019-03-29 16:59:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
noecho();
|
|
|
|
cbreak();
|
|
|
|
|
2019-03-29 19:35:22 -04:00
|
|
|
printw("New file, \"%s\".\n\n", param.c_str());
|
2019-03-29 16:59:38 -04:00
|
|
|
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;
|
|
|
|
}
|