73 lines
1.1 KiB
C++
73 lines
1.1 KiB
C++
#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;
|
|
}
|