隐藏的密文

隐藏的密文


听说有一种软件,可以将一定的密文隐藏在图形文件中,我没有用过,不过这个想法很好,嗯……我的意思是正好作为我的练习。
于是我打开winhex,试了各种不同后缀的图形文件,发现很少有油水可以榨取:jpg和gif还说得过去,本来就是压缩过的嘛,那个bmp(dib)简直是财迷到了极点,根本没有什么地方可用。最后呢,还是发现.pcx有些地方可用,经过我一番捣鼓(说起来简单,实际耗了我好几个小时。啊?为什么是几个小时?因为我笨啊!这个都不知道。),发现文件尾有2d0h个字节可用。不要小看这七百多个字节,如果是情书,全写上肉麻的话足可以当杀伤性武器用了。不过为了避免惨剧的发生,最好还是把这类东西藏起来,藏哪儿呢?.pcx中!看我的代码:

#include<stdio.h>
class MessageInPcx
{
protected:
FILE *in, *out;
FILE *input;
long filesize(FILE *stream)
{
long curpos, length;
curpos = ftell(stream);
fseek(stream, 0L, SEEK_END);
length = ftell(stream);
fseek(stream, curpos, SEEK_SET);
return length;
}
void DoTheJob(char filename[12])
{
if((input = fopen(filename, "rb"))==NULL)
return;
for(int i=0; i<(filesize(in)-715); i++)
putc(getc(in), out);
for(i=0; i<715; i++)
{
if(!feof(input))
putc(getc(input), out);
else
putc('\0', out);
}
fcloseall();
}
public:
MessageInPcx()
{
out = fopen("out.pcx", "wb");
}
void setpcx(char filename[12])
{
in = fopen(filename, "rb");
}
void operator <<= (char filename[12])
{
DoTheJob(filename);
return;
}
};
void main()
{
MessageInPcx out;
out.setpcx("hehe.pcx");
out <<= "a.txt";
}

可以把MessageInPcx直接拿来用,编译时有一个warning,不管它!
中华技术网整理发布 http://www.asfocus.com http://www.netqu.com

 



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=3348


你可能感兴趣的:(隐藏)