-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,137 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Change Log | ||
Program versioning follows SemVer. | ||
|
||
## Version 1.0.0 - Oct, 12, 2018 | ||
|
||
Initial release. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
CMAKE_MINIMUM_REQUIRED (VERSION 3.12) | ||
PROJECT (nXORE) | ||
|
||
#Program Version | ||
SET (nXORE_VERSION_MAJOR 1) | ||
SET (nXORE_VERSION_MINOR 0.0) | ||
|
||
#Find Boost Library | ||
set (Boost_USE_STATIC_LIBS ON) | ||
set (Boost_USE_DEBUG_LIBS OFF) | ||
set (Boost_USE_RELEASE_LIBS ON) | ||
set (Boost_USE_MULTITHREADED ON) | ||
set (Boost_USE_STATIC_RUNTIME OFF) | ||
|
||
find_package (Boost 1.65.0 REQUIRED COMPONENTS | ||
system filesystem) | ||
|
||
if (Boost_FOUND) | ||
include_directories (${Boost_INCLUDE_DIRS}) | ||
else() | ||
Message ("Boost Library not found...") | ||
RETURN() | ||
endif() | ||
|
||
#Find Curses Library | ||
find_package (Curses REQUIRED) | ||
|
||
if (CURSES_FOUND) | ||
include_directories (${CURSES_INCLUDE_DIRS}) | ||
else() | ||
Message ("nCurses library not found...") | ||
RETURN() | ||
endif() | ||
|
||
#Set up program | ||
include_directories (src) | ||
set (CMAKE_CXX_STANDARD 11) | ||
set (CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin) | ||
set (EXECUTABLE_OUTPUT ${CMAKE_BINARY_DIR}) | ||
set (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) | ||
|
||
#Add executable program | ||
FILE (GLOB xoreSrc src/*.cpp) | ||
add_executable (nXORE ${xoreSrc}) | ||
|
||
#Linking the main program | ||
target_link_libraries (nXORE ${Boost_LIBRARIES} ${CURSES_LIBRARIES} | ||
-lboost_system -lboost_filesystem -lncurses | ||
-lform -lmenu) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
What you need is Boost and nCurses library and follow these steps : | ||
|
||
1. Go to inside the nXORE folder | ||
2. mkdir bin | ||
3. cd bin | ||
4. cmake .. | ||
5. make | ||
6. ./nXORE | ||
|
||
you can also use cmake-gui. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
# nXORE | ||
|
||
## Version 1.0.0 | ||
nXORE - is a simple CUI based encryptor program that uses XOR cipher encryption method. | ||
|
||
## Prerequisites | ||
What you need to compile this program is `Boost` and `nCurse` library. | ||
|
||
## Compiles | ||
Follow these steps to compile the program. | ||
``` | ||
|
@@ -14,24 +17,31 @@ Follow these steps to compile the program. | |
6. ./nXORE | ||
``` | ||
Or you could also use cmake-gui. | ||
|
||
## Usage | ||
1. Open the program, it's better to run it with sudo command `sudo ./nXORE`. | ||
2. After that, you need to login. The default password is `root`, you may change it later in the setting. | ||
3. Set key first before to encrypt in the **SELECT KEY** option. | ||
4. Select the file in **SELECT FILES** option. Press right key to select and spacebar if you done. | ||
5. Finally, choose **ENCRYPT/DECRYPT** option to encrypt or decrypt it depending the files. | ||
|
||
## Known Limitations | ||
* For now, it only could select multiple files in the **same folder**. | ||
* The encrypted/decrypted result will be placed same as the original files path. | ||
* Using simple setting storage. | ||
|
||
## Known Bugs | ||
|
||
## Change Log | ||
See [CHANGELOG.md]() for more. | ||
See [CHANGELOG.md](CHANGELOG.md) for more. | ||
|
||
## Built With | ||
* [Code::Blocks](http://www.codeblocks.org/) - My favorite C/C++ IDE | ||
* [nCurse](https://www.gnu.org/software/ncurses/) - For the console graphic | ||
* [Boost](https://www.boost.org/) - For file management | ||
|
||
## Contributors | ||
Ivan Ongko Sampurna(Cathean) - [email protected] | ||
|
||
## License & Copyright | ||
See [LICENSE.md]() for more. | ||
See [LICENSE.md](LICENSE.md) for more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "include/Encryptor.h" | ||
|
||
std::string Encryptor::xor_encryptor(std::string buffer) | ||
{ | ||
std::string encrypted_buffer = buffer; | ||
|
||
for(int i = 0; i < buffer.size(); i++) | ||
encrypted_buffer[i] = buffer[i] ^ key[i % key.length()]; | ||
|
||
return encrypted_buffer; | ||
} | ||
|
||
std::string Encryptor::Istr_encryptor(std::string buffer) | ||
{ | ||
std::string encrypted_buffer = buffer; | ||
|
||
if(buffer[buffer.size() - 1] != 'n') | ||
{ | ||
for(int i = 0; i < buffer.size(); i++) | ||
{ | ||
if(buffer[i] == '.') | ||
encrypted_buffer[i] = '}'; | ||
else | ||
encrypted_buffer[i] = char(++buffer[i]); | ||
} | ||
|
||
encrypted_buffer += "n"; | ||
} | ||
else | ||
{ | ||
encrypted_buffer.pop_back(); | ||
|
||
for(int i = 0; i < buffer.size(); i++) | ||
{ | ||
if(buffer[i] == '}') | ||
encrypted_buffer[i] = '.'; | ||
else | ||
encrypted_buffer[i] = char(--buffer[i]); | ||
|
||
} | ||
} | ||
|
||
return encrypted_buffer; | ||
} | ||
|
||
void Encryptor::set_key(std::string k) | ||
{ | ||
key = k; | ||
} | ||
|
||
int Encryptor::file_encrypt(std::string origin_path, std::string output_path) | ||
{ | ||
std::ifstream t(origin_path); | ||
std::string buffer(std::istreambuf_iterator<char>(t), {}); | ||
std::ofstream out(output_path); | ||
|
||
out << xor_encryptor(buffer); | ||
t.close(); | ||
out.close(); | ||
} | ||
|
||
std::string Encryptor::str_encrypt(std::string str) | ||
{ | ||
return Istr_encryptor(str); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#include "include/MenuForm.h" | ||
|
||
MenuForm::MenuForm(std::vector<std::string> names, std::vector<std::string> desc, int arrsize) | ||
{ | ||
boxv = 0; | ||
boxh = 0; | ||
item_size = arrsize; | ||
|
||
for(int i = 0; i < arrsize; i++) | ||
{ | ||
optnames.push_back(names[i]); | ||
optdesc.push_back(desc[i]); | ||
} | ||
|
||
optnames.push_back(std::string()); | ||
optdesc.push_back(std::string()); | ||
} | ||
|
||
MenuForm::~MenuForm() | ||
{ | ||
unpost_menu(menu); | ||
free_menu(menu); | ||
|
||
for(int i = 0; i < item_size + 1; i++) | ||
free_item(item[i]); | ||
|
||
delete [] item; | ||
|
||
delwin(loc_win); | ||
} | ||
|
||
int MenuForm::set_color(int window_background, int menu_color) | ||
{ | ||
winbk = window_background; | ||
menbk = menu_color; | ||
} | ||
|
||
int MenuForm::set_win_pos(int lines, int cols, int starty, int startx) | ||
{ | ||
wl = lines; | ||
wc = cols; | ||
wy = starty; | ||
wx = startx; | ||
} | ||
|
||
int MenuForm::set_menu_pos(int lines, int cols, int starty, int startx) | ||
{ | ||
ml = lines; | ||
mc = cols; | ||
my = starty; | ||
mx = startx; | ||
} | ||
|
||
int MenuForm::set_box_style(int v, int h) | ||
{ | ||
boxv = v; | ||
boxh = h; | ||
} | ||
|
||
int MenuForm::init() | ||
{ | ||
item = new ITEM *[item_size + 1]; | ||
|
||
for(int i = 0; i < item_size + 1; i++) | ||
item[i] = new_item(optnames[i].c_str(), optdesc[i].c_str()); | ||
|
||
menu = new_menu(item); | ||
loc_win = newwin(wl, wc, wy, wx); | ||
|
||
keypad(loc_win, TRUE); | ||
set_menu_win(menu, loc_win); | ||
set_menu_sub(menu, derwin(loc_win, ml, mc, my, mx)); | ||
set_menu_mark(menu, ">"); | ||
set_menu_back(menu, COLOR_PAIR(menbk)); | ||
wbkgd(loc_win, COLOR_PAIR(winbk)); | ||
|
||
box(loc_win, boxv, boxh); | ||
refresh(); | ||
} | ||
|
||
void MenuForm::post() | ||
{ | ||
post_menu(menu); | ||
refresh(); | ||
wrefresh(loc_win); | ||
} | ||
|
||
void MenuForm::unpost() | ||
{ | ||
unpost_menu(menu); | ||
refresh(); | ||
wrefresh(loc_win); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "include/PassTextForm.h" | ||
|
||
std::string PassTextForm::get_pass() | ||
{ | ||
std::string p(pass.begin(), pass.end()); | ||
|
||
return p; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "include/PathIterate.h" | ||
|
||
PathIterate::PathIterate() | ||
{ | ||
count_data = 0; | ||
} | ||
|
||
PathIterate::~PathIterate() | ||
{ | ||
|
||
} | ||
|
||
int PathIterate::set_path(std::string p) | ||
{ | ||
loc_path = p; | ||
|
||
try | ||
{ | ||
if(bfs::exists(p)) | ||
return RET_NORM; | ||
} | ||
catch(const bfs::filesystem_error &ex) | ||
{ | ||
printw("%s", ex.what()); | ||
} | ||
} | ||
|
||
int PathIterate::iterate_dir() | ||
{ | ||
std::vector<bfs::path> v; | ||
|
||
try | ||
{ | ||
if(bfs::is_regular_file(loc_path)) | ||
return RET_NORM; | ||
else if(bfs::is_directory(loc_path)) | ||
{ | ||
for(auto&& x : bfs::directory_iterator(loc_path)) | ||
v.push_back(x.path()); | ||
|
||
v.push_back("."); | ||
v.push_back(".."); | ||
std::sort(v.begin(), v.end()); | ||
|
||
for(auto&& x : v) | ||
{ | ||
vname.push_back(x.filename().string()); | ||
|
||
if(bfs::is_regular_file(x)) | ||
vdesc.push_back("<FILE>"); | ||
else if(bfs::is_directory(x)) | ||
vdesc.push_back("<DIR>"); | ||
else | ||
vdesc.push_back("<???>"); | ||
|
||
count_data++; | ||
} | ||
} | ||
} | ||
catch(const bfs::filesystem_error &ex) | ||
{ | ||
printw("%s", ex.what()); | ||
} | ||
} |
Oops, something went wrong.