Compare commits
2 Commits
8e8ad60d9e
...
9afed448df
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9afed448df | ||
|
|
5b45337d98 |
37
README.md
37
README.md
@@ -0,0 +1,37 @@
|
||||
# PSPNG
|
||||
|
||||
Sample program to embed messages into PNG images
|
||||
|
||||
## Install
|
||||
|
||||
**NOTE:** Set the core_count variable to one value lower than maximum cores on the host in cmd/pspng.c
|
||||
|
||||
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
|
||||
|
||||
|
||||
16
cmd/pspng.c
16
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
|
||||
@@ -262,12 +265,13 @@ static int crc_embed_data(unsigned char *data, unsigned int data_length, int bit
|
||||
raw_data = create_raw_pixel_values(data, bit_width, color_range, sliding_window);
|
||||
random_window_bit_change(data, raw_data, bit_width, 2, color_range, sliding_window, offset);
|
||||
|
||||
if(offset > 500000) {
|
||||
//if(offset > 500000) {
|
||||
if(offset == -1) {
|
||||
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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user