LSB图像隐写

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

图像隐藏技术实现与检测

(1.LSB隐写技术;2.LSB隐写检测;)

摘要:LSB替换隐写基本思想是用嵌入的秘密信息取代载体图像的最低比特位,原来的的7个高位平面与替代秘密信息的最低位平面组合成含隐藏信息的新图形。文章首先简单叙述了BMP位图文件的文件格式,然后根据24位真彩色BMP位图格式与显示方式的特殊性,直接改变图像中像素的最后一位值来嵌入秘密文件,提出了一种对文字信息进行加密的有效方案。

关键字:LSB,信息隐藏,信息安全,BMP位图

Image hiding technology implementation

and testing

(1.LSB steganography technology;2.LSB

steganography detection)

Abstract:LSB replacement steganography basic idea is to use the embedded secret information to replace the image of the lowest bits, the original 7 high plane and the least significant bit plane of alternative secret information into new graphics containing hidden information.This paper simple describes the BMP file format of the

bitmap file, and then according to the 24 true color BMP bitmap format and the particularity of display mode, directly change the values of pixels in the image of the last to embed secret files, puts forward a effective scheme of text information is encrypted. Keywords:LSB, Information hiding,information security,bit map file

1.背景知识

在编制本算法之前,我们必须了解一些辅助知识,以便我们能够读懂为什么要这样编制程序。首先,我们要了解24位真彩色

BMP(Bitmap-File)格式位图的文件结构。位图文件头位图信息头色表实际位图数据图典型BMP文件结构示意图一个典型的位图文件可看成由4个部分组成:位图文件头(bitmap-fileheader)、位图信息头(bitmap-informationheader)、色表(colortable)和实际位图数据的字节阵列,其具体形式如图1所示。其中前面3个部分包含关于这个图形文件的信息,这3个部分,占据了一个24位真彩色BMP位图文件的前54个字节。

2.LSB隐写的实现

LSB的实现就是把bmp位图的数据部分的最低位以此替换成所要隐藏的信息。实现的C语言代码如下:

#include "stdafx.h"

#include "stdio.h"

#include "string.h"

int main(int argc, char* argv[])

{

FILE *in,*out;

int i;

char inFileName[90],outFileName[90];

printf("请输入原位图文件的文件名: \n");

scanf("%s",inFileName);

printf("请输入处理后的文件的文件名: \n");

scanf("%s",outFileName);

if((in=fopen(inFileName,"rb"))==NULL)

{

printf("文件无法打开!\n");

return -1;

}

if((out=fopen(outFileName,"wb"))==NULL)

{

printf("文件无法打开!\n");

return -1;

}

for(i=1;!feof(in);i++)

{

if(i<=54)

{

fputc(fgetc(in),out);

}

else

{

fputc(~fgetc(in),out);

}

}

printf("图片处理成功!\n");

fclose(in);

fclose(out);

return 0;

}

实现效果:

(原图)(处理后的图片)3.LSB隐写检测

3.1直接使用C语言代码将刚才隐写的信息显示出来。

代码:#include "stdafx.h"

#include "stdio.h"

int main(int argc, char* argv[])

{

FILE *in;

char ch,fileName[90];

unsigned int i;

printf("enter fileName: \n");

scanf("%s",fileName);

if((in=fopen(fileName,"rb"))==NULL)

{

printf("file open fail");

return -1;

}

fseek(in,54L,0);

do

{

ch =0 ;

for(i=0;i<8;i++)

{

ch+=(fgetc(in)&0x01)<

}

putchar(ch);

}while(ch);

相关文档
最新文档