summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPin <wf6DJd8a3xSSCZbn@protonmail.com>2021-12-03 18:41:30 -0500
committerPin <wf6DJd8a3xSSCZbn@protonmail.com>2021-12-03 18:41:30 -0500
commit5b45337d98ad1930059c9c7e77cab63442249a86 (patch)
tree9a781f142e84bf9553772c69db07e1249c7539c5
parent8e8ad60d9eec7d84c37271810cb5fc09151f82de (diff)
Added README and other changes
-rw-r--r--README.md35
-rw-r--r--cmd/pspng.c13
-rw-r--r--src/compress_util.c1
3 files changed, 44 insertions, 5 deletions
diff --git a/README.md b/README.md
index e69de29..6b6a3e7 100644
--- a/README.md
+++ b/README.md
@@ -0,0 +1,35 @@
+# PSPNG
+
+Sample program to embed messages into PNG images
+
+## Install
+
+Requires zlib, pthread, and sodium header files to compile (These will be distro specific packages)
+
+Build:
+
+```bash
+make
+```
+
+System Wide:
+
+```bash
+make
+make install
+```
+
+## Usage
+
+Embed Message:
+
+pspng --compress -f {input file name} -o {output file name} -m "{input message}"
+
+Extract Message:
+
+pspng --uncompress -f {input file name}
+
+Help Message:
+
+pspng --help
+
diff --git a/cmd/pspng.c b/cmd/pspng.c
index 1e89d69..2bf9d7a 100644
--- a/cmd/pspng.c
+++ b/cmd/pspng.c
@@ -187,14 +187,17 @@ static void random_window_bit_change(unsigned char *data, unsigned char *raw_dat
raw_data[random_num]++;
}
// Update Current Pixel
- data[random_num] = raw_data[random_num] - floor((raw_data[random_num-color_range] + raw_data[random_num-((width * color_range) + 1)]) / 2);
+ data[random_num] = raw_data[random_num] - floor((raw_data[random_num-color_range] +
+ raw_data[random_num-((width * color_range) + 1)]) / 2);
// Fixing Next Pixel in Scanline
if(!(random_num+color_range > (filter_chunk_byte + (width * color_range) + 1))){
- data[random_num+color_range] = raw_data[random_num+color_range] - floor((raw_data[random_num] + raw_data[random_num-((width * color_range)+ 1)+color_range]) / 2);
+ data[random_num+color_range] = raw_data[random_num+color_range] -
+ floor((raw_data[random_num] + raw_data[random_num-((width * color_range)+ 1)+color_range]) / 2);
}
// Checking Next Scanline type
if(data[filter_chunk_byte+((width * color_range) + 1)] == 3){
- data[random_num+((width * color_range)+1)] = raw_data[random_num+((width * color_range)+1)] - floor((raw_data[random_num+((width * color_range)+1)-color_range] + raw_data[random_num]) / 2);
+ data[random_num+((width * color_range)+1)] = raw_data[random_num+((width * color_range)+1)] -
+ floor((raw_data[random_num+((width * color_range)+1)-color_range] + raw_data[random_num]) / 2);
}
} else if(data[filter_chunk_byte] == 4) {
// Add Support
@@ -265,9 +268,9 @@ static int crc_embed_data(unsigned char *data, unsigned int data_length, int bit
if(offset > 500000) {
new_data = calloc(300000, sizeof(unsigned char));
for(int k = 0; k < 300000; k++) {
- new_data[k] = data[offset-(offset-prior_offset)+k];
+ new_data[k] = data[offset-(offset-prior_offset-1)+k];
}
- zlib_compress_data(new_data, 110000, &check_data, &check_data_length);
+ zlib_compress_data(new_data, 100000, &check_data, &check_data_length);
match_crc = verify_crc_chunks(check_data, check_data_length, 1, MAX_IDAT_SIZE, message, 1);
} else {
zlib_compress_data(data, data_length, &check_data, &check_data_length);
diff --git a/src/compress_util.c b/src/compress_util.c
index 9407c8a..5764cbf 100644
--- a/src/compress_util.c
+++ b/src/compress_util.c
@@ -82,6 +82,7 @@ void zlib_compress_data(unsigned char *data_chunk, size_t file_length, unsigned
unsigned char out[CHUNK];
int level = 9;
int method = Z_DEFLATED;
+ //int windowBits = 15;
int windowBits = 10;
int memLevel = 9;
//int strategy = Z_DEFAULT_STRATEGY;