資源簡介
BMP圖像的信息隱藏BMP圖像的信息隱藏BMP圖像的信息隱藏BMP圖像的信息隱藏

代碼片段和文件信息
#include
#include
#include“math.h“
#include“lsb.h“
#include“windows.h“
using?namespace?std;
//定義構造函數
LSB::LSB()
{
m_bitmapfileheader=new?BITMAPFILEHEADER;
m_bitmapinfoheader=new?BITMAPINFOHEADER;
m_colortable=NULL;
m_data=NULL;
max_bitmaplength=0;
char?*strByteBuffer=NULL;
int?hidelength=0;
}
//定義析構函數
LSB::~LSB()
{
delete?m_bitmapfileheader;
delete?m_bitmapinfoheader;
delete?m_colortable;
delete?m_data;
delete?strByteBuffer;
}
//讀取BMP圖像到內存
void?LSB::readBMP(char?*bmpname)
{
ifstream?file;
char?m_bmpname[255];
strcpy(m_bmpnamebmpname);
int?biBitCount;?//BMP圖像的深度
file.open(m_bmpname?ios::out?|?ios::in?|?ios::binary);
file.read((char?*)m_bitmapfileheadersizeof(BITMAPFILEHEADER));
file.read((char?*)m_bitmapinfoheadersizeof(BITMAPINFOHEADER));
????biBitCount=m_bitmapinfoheader->biBitCount;
if(biBitCount==2||biBitCount==4||biBitCount==8)
{
m_colortable=new?RGBQUAD[pow(2biBitCount)];
file.read((char?*)m_colortablepow(2biBitCount)*sizeof(RGBQUAD));
}
m_data=new?char[(m_bitmapinfoheader->biSizeImage+1)];
file.read((char?*)m_datam_bitmapinfoheader->biSizeImage);
max_bitmaplength=(m_bitmapinfoheader->biSizeImage)/8;
cout<<“該BMP圖像最大能隱藏的信息量為:?“< }
//讀取隱藏文件到緩沖區
void?LSB::readHide(char?*hidename)
{
ifstream?hidefile;
hidefile.open(hidename?ios::binary?|?ios::in);
hidefile.seekg(0hidefile.end);
hidelength=hidefile.tellg();
cout<<“該隱藏文件信息量為:?“<
//判斷是否能完成信息隱藏,若不能退出程序
if(max_bitmaplength {
cout<<“隱藏的文件信息量過大“< return;
}
//將隱藏文件信息讀入緩沖區
strByteBuffer=new?char[hidelength];
hidefile.seekg(0hidefile.beg);
hidefile.read((char?*)strByteBufferhidelength);
hidefile.close();
}
//創建已經隱藏了信息的BMP圖像
void?LSB::createBMP(char?*createbmp)
{
ofstream?dibFile;
int?biBitCount;
dibFile.open(createbmp?ios::out?|?ios::binary);
dibFile.write((char*)m_bitmapfileheadersizeof(BITMAPFILEHEADER));
dibFile.write((char*)m_bitmapinfoheadersizeof(BITMAPINFOHEADER));
????biBitCount=m_bitmapinfoheader->biBitCount;
if(biBitCount==2||biBitCount==4||biBitCount==8)
{
dibFile.write((char?*)m_colortablepow(2biBitCount)*sizeof(RGBQUAD));
}
dibFile.write((char?*)m_datam_bitmapinfoheader->biSizeImage);
dibFile.close();
cout<<“隱藏信息完畢“< }
//創建提取信息的文件
void?LSB::createFile(char?*getfilechar?*strByteBufferint?HideLength)
{
ofstream?outfile;
outfile.open(getfile?ios::out?|?ios::binary);
outfile.write((char?*)strByteBufferHideLength);
outfile.close();
delete?strByteBuffer;
cout<<“信息已提取“< }
//用LSB算法隱藏文件
void?LSB::LSBhide(char?*bmpnamechar?*hidename)
{
????int?ij;
char?createbmp[255];
readBMP(bmpname);
readHide(hidename);
//BMP圖像數據區的前32個字節用來記錄隱藏文件數據長度
for(i=0;i<32;i++)
{
m_data[i]=?((hidelength>>(31-i))?&?0x00000001)+(m_data[i]&0xfe);
}
//基于LSB算法隱藏文件信息
for(i=0;i {
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????985??2010-04-18?23:06??單張BMP圖像的信息隱藏\lsb.h
?????文件????????533??2010-04-18?18:22??單張BMP圖像的信息隱藏\tao.txt
?????文件???????3974??2010-04-18?23:06??單張BMP圖像的信息隱藏\lsb.cpp
?????文件????????916??2010-04-18?23:10??單張BMP圖像的信息隱藏\main.cpp
?????文件??????48640??2010-04-18?23:10??單張BMP圖像的信息隱藏\單張BMP圖像的信息隱藏.opt
?????文件????????550??2010-04-17?21:52??單張BMP圖像的信息隱藏\單張BMP圖像的信息隱藏.dsw
?????文件??????50176??2010-04-18?23:10??單張BMP圖像的信息隱藏\單張BMP圖像的信息隱藏.ncb
?????文件????????966??2010-04-18?23:10??單張BMP圖像的信息隱藏\單張BMP圖像的信息隱藏.plg
?????文件???????4565??2010-04-17?23:23??單張BMP圖像的信息隱藏\單張BMP圖像的信息隱藏.dsp
?????文件??????41984??2010-04-18?12:43??單張BMP圖像的信息隱藏\lsb.ncb
?????文件???????1498??2010-04-18?12:43??單張BMP圖像的信息隱藏\lsb.plg
?????文件???????3365??2010-04-18?12:43??單張BMP圖像的信息隱藏\lsb.dsp
?????文件??????48640??2010-04-18?12:43??單張BMP圖像的信息隱藏\lsb.opt
?????文件????????514??2010-04-18?12:43??單張BMP圖像的信息隱藏\lsb.dsw
?????文件?????462654??2010-04-10?18:40??單張BMP圖像的信息隱藏\1.bmp
?????文件??????25600??2009-11-07?10:54??單張BMP圖像的信息隱藏\tao.doc
?????文件??????25600??2010-04-18?16:37??單張BMP圖像的信息隱藏\createbmp
?????文件?????205824??2010-04-18?23:10??單張BMP圖像的信息隱藏\Debug\vc60.idb
?????文件?????151552??2010-04-18?23:10??單張BMP圖像的信息隱藏\Debug\vc60.pdb
?????文件????1997944??2010-04-17?22:14??單張BMP圖像的信息隱藏\Debug\單張BMP圖像的信息隱藏.pch
?????文件?????916072??2010-04-18?23:10??單張BMP圖像的信息隱藏\Debug\單張BMP圖像的信息隱藏.ilk
?????文件?????310900??2010-04-18?23:06??單張BMP圖像的信息隱藏\Debug\lsb.obj
?????文件?????208689??2010-04-18?23:10??單張BMP圖像的信息隱藏\Debug\main.obj
?????文件????1451008??2010-04-18?23:10??單張BMP圖像的信息隱藏\Debug\單張BMP圖像的信息隱藏.pdb
?????文件????5473304??2010-04-18?12:40??單張BMP圖像的信息隱藏\Debug\lsb.pch
?????文件?????626810??2010-04-18?23:10??單張BMP圖像的信息隱藏\Debug\單張BMP圖像的信息隱藏.exe
?????目錄??????????0??2010-04-19?16:26??單張BMP圖像的信息隱藏\Debug
?????目錄??????????0??2010-04-19?16:26??單張BMP圖像的信息隱藏
-----------?---------??----------?-----??----
?????????????12063263????????????????????28
............此處省略1個文件信息
評論
共有 條評論