Added README and other changes

This commit is contained in:
Pin
2021-12-03 18:41:30 -05:00
parent 8e8ad60d9e
commit 5b45337d98
3 changed files with 44 additions and 5 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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;