Skip to content

Commit

Permalink
v 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ouranos committed Oct 24, 2021
1 parent 824079a commit 2175662
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion includes/decrypt.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef DECRYPT_HPP
#define DECRYPT_HPP

unsigned char *decrypt(char* encyrpted_text, char *passphrase);
unsigned char *decrypt(char* encrypted_text, char *passphrase);

#endif
11 changes: 5 additions & 6 deletions src/decrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../lib/Blowfish/blowfish.h"
#include <string.h>

unsigned char *decrypt(char* encyrpted_text, char *passphrase){
unsigned char *decrypt(char* encrypted_text, char *passphrase){
if(passphrase == NULL){
passphrase = "mypassphrase";
}else{
Expand All @@ -11,12 +11,11 @@ unsigned char *decrypt(char* encyrpted_text, char *passphrase){
exit(0);
}
}
unsigned char unsigned_content[strlen(encyrpted_text) + 5] = {0} ;

unsigned char unsigned_content[strlen(encrypted_text) + 5] = {0} ;
int i = 0 ;
while(i < strlen(encyrpted_text)){
unsigned_content[i] = encyrpted_text[i];
i++;
}
strncpy((char *)unsigned_content, encrypted_text, strlen(encrypted_text));
// converting to unsigned keys
i = 0;
unsigned char unsigned_key[strlen(passphrase) + 5] = {0} ;
while(i < strlen(passphrase)){
Expand Down
8 changes: 4 additions & 4 deletions src/embed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ void embed(char* coverfile, char* embedingfile, char* passphrase, char* outputfi
// when reading the header using extract.cpp the x added here will be removed and the strings will be converted to ints to get the right values
// reading these header maybe will crash when using bigest files "more than 9999" so this is temporarely until i change it
while(i < 7){
if(s_array[i] < 9){
if(s_array[i] <= 9){
string_cover_content.insert(f , std::to_string(s_array[i]) + "xxx");
}else if(s_array[i] < 99){
}else if(s_array[i] <= 99){
string_cover_content.insert(f , std::to_string(s_array[i]) + "xx"); // the x appended to the file are used to make every int take 4 bytes, i thought adding null bytes would be better but null bytes are used as string terminators, x's are used temporarily until i find a better solution
}else if(s_array[i] < 999){
}else if(s_array[i] <= 999){
string_cover_content.insert(f , std::to_string(s_array[i]) + "x");
}else if(s_array[i] < 9999){
}else if(s_array[i] <= 9999){
string_cover_content.insert(f , std::to_string(s_array[i]));
}
i++;
Expand Down
4 changes: 2 additions & 2 deletions src/extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ void extract(char* stegfile, char* passphrase, char* outputfile, bool encryption
container += d ;
char encrypted_text[container.length() + 10];
strcpy(encrypted_text, container.c_str());
encrypted_text[header.s_sizef] = '\0';
std::cout << encrypted_text;
encrypted_text[header.s_sizef +1] = '\0';
// decrypting the data extracted
char *con = encrypted_text ;
unsigned char* unsig_container = decrypt(con, passphrase);
std::cout << unsig_container;
// storing it into a file
FILE *output;
output = fopen(outputfile, "w");
Expand Down

0 comments on commit 2175662

Please sign in to comment.