小编use*_*536的帖子

C中的隐写术

尝试在PPM图像上进行基本的隐写术.

我已完成基本算法.读入文件,检查标题以P6开头,获取图像的宽度和高度,以及像素数据.

我需要总共有四种方法:ReadPPM,WritePPM,WriteMsg和ReadMsg.

我有ReadImg和WriteImg方法,但我遇到的是我的WriteMsg方法.这是基本的隐写术,只是将字符串的每个位写入每个字节的最后一位.假设前8个字节包含被隐藏的字符串的大小,然后每个字节开始隐藏的消息.

我的想法是创建一个大型数组,其中包含字符串大小的二进制代码,然后是字符串本身的二进制代码.我只想弄清楚如何将该数组添加到图像中的每个字节.

任何帮助深表感谢.这是我目前的代码:

#include<stdio.h>
#include<stdlib.h>

typedef struct {
     unsigned char red,green,blue;
} PPMPixel;

typedef struct {
     int x, y;
     PPMPixel *data;
} PPMImage;

#define CREATOR "RPFELGUEIRAS"
#define RGB_COMPONENT_COLOR 255

static PPMImage *readPPM(const char *filename)
{
    char buff[16];
    PPMImage *img;
    FILE *fp;
    int c, rgb_comp_color;
    //open PPM file for reading
    fp = fopen(filename, "rb");
    if (!fp) {
         fprintf(stderr, "Unable to open file '%s'\n", filename);
         exit(1);
    }

    //read image format
    if (!fgets(buff, sizeof(buff), fp)) {
         perror(filename);
         exit(1);
    }

    //check …
Run Code Online (Sandbox Code Playgroud)

c steganography pixel image-processing ppm

6
推荐指数
1
解决办法
7548
查看次数

标签 统计

c ×1

image-processing ×1

pixel ×1

ppm ×1

steganography ×1