Added README and other changes
This commit is contained in:
35
README.md
35
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
|
||||||
|
|
||||||
|
|||||||
13
cmd/pspng.c
13
cmd/pspng.c
@@ -187,14 +187,17 @@ static void random_window_bit_change(unsigned char *data, unsigned char *raw_dat
|
|||||||
raw_data[random_num]++;
|
raw_data[random_num]++;
|
||||||
}
|
}
|
||||||
// Update Current Pixel
|
// 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
|
// Fixing Next Pixel in Scanline
|
||||||
if(!(random_num+color_range > (filter_chunk_byte + (width * color_range) + 1))){
|
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
|
// Checking Next Scanline type
|
||||||
if(data[filter_chunk_byte+((width * color_range) + 1)] == 3){
|
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) {
|
} else if(data[filter_chunk_byte] == 4) {
|
||||||
// Add Support
|
// Add Support
|
||||||
@@ -265,9 +268,9 @@ static int crc_embed_data(unsigned char *data, unsigned int data_length, int bit
|
|||||||
if(offset > 500000) {
|
if(offset > 500000) {
|
||||||
new_data = calloc(300000, sizeof(unsigned char));
|
new_data = calloc(300000, sizeof(unsigned char));
|
||||||
for(int k = 0; k < 300000; k++) {
|
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);
|
match_crc = verify_crc_chunks(check_data, check_data_length, 1, MAX_IDAT_SIZE, message, 1);
|
||||||
} else {
|
} else {
|
||||||
zlib_compress_data(data, data_length, &check_data, &check_data_length);
|
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];
|
unsigned char out[CHUNK];
|
||||||
int level = 9;
|
int level = 9;
|
||||||
int method = Z_DEFLATED;
|
int method = Z_DEFLATED;
|
||||||
|
//int windowBits = 15;
|
||||||
int windowBits = 10;
|
int windowBits = 10;
|
||||||
int memLevel = 9;
|
int memLevel = 9;
|
||||||
//int strategy = Z_DEFAULT_STRATEGY;
|
//int strategy = Z_DEFAULT_STRATEGY;
|
||||||
|
|||||||
Reference in New Issue
Block a user