資源簡介
1、隱寫:分別完成位圖格式圖像頭文件冗余、圖片尾部追加和數(shù)據(jù)區(qū)覆蓋三種隱寫。
2、分析:分別完成位圖格式圖像頭文件冗余、圖片尾部追加和數(shù)據(jù)區(qū)覆蓋三種隱寫圖像與正常圖像的分析及隱寫數(shù)據(jù)的提取。

代碼片段和文件信息
//?BMP.cpp:?implementation?of?the?BMP?class.
//
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
#include?“BMP.h“
#include?
#include?
using?namespace?std;
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
BMP::BMP()
{
}
BMP::~BMP()
{
}
bool?BMP::setBmpFileName(char?*szFileName)
{
memcpy(nameszFileName100);
//strcat(name“.yuan.bmp“);
this->sBmpFileName?=?szFileName;
if?(pBuf) //如果已經(jīng)生成就釋放掉
{
//cout<<“sss“< //delete?pBuf;
}
HANDLE?hfile?=?CreateFileA(szFileName?GENERIC_READ?|?GENERIC_WRITE?FILE_SHARE_READ?|?FILE_SHARE_WRITE?NULL?OPEN_EXISTING?0?0);
if(hfile?==INVALID_HANDLE_VALUE)
{
cout<<“打開文件失敗或者沒有此文件!“< return?false;
}
dwBmpSize?=?GetFileSize(hfile?0);?//獲取文件的大小
pBuf?=?new?unsigned?char[dwBmpSize];
DWORD?dwRead?=?0;
ReadFile(hfile?pBuf?dwBmpSize?&dwRead?0);
if?(dwRead?!=?dwBmpSize)
{
delete[]pBuf;
pBuf?=?0;
return?false;
}
CloseHandle(hfile);
m_fileHdr?=?(BITMAPFILEHEADER*)pBuf;
m_infoHdr?=?(BITMAPINFOHEADER*)(pBuf?+?sizeof(BITMAPFILEHEADER));
return?true; //成功話就是文件的內(nèi)容讀取到pBuf里面
}
bool?BMP::save(int?index)
{
string?sDstFileName?=?sBmpFileName?+?“.yuan.bmp“;
HANDLE?hfile?=?CreateFileA(sDstFileName.c_str()
GENERIC_READ?|?GENERIC_WRITE
FILE_SHARE_READ?|?FILE_SHARE_WRITE
NULL
CREATE_ALWAYS?0?0);
if?(hfile?==?INVALID_HANDLE_VALUE)
{
return?false;
}
//在一個文件中設(shè)置當(dāng)前的讀取位置
SetFilePointer(hfile?0?0?FILE_BEGIN);
DWORD?dwWritten?=?0;
WriteFile(hfile?pBuf?dwBmpSize?&dwWritten?0);
if?(dwBmpSize?!=?dwWritten)
{
return?false;
}
CloseHandle(hfile);
return?true;
}
bool?BMP::headhideBMP(char?*s)?//頭文件隱寫hell
{
//char?s[10]=“hell“;
int?num[8]={0};
int?index?=?0i;
for(i=0;i {
int?in=s[i];
num[index++]=in/16;
num[index++]=in%16;
}
while(index<8)
{
num[index++]=0;
}
int?m=0n=0;
int?s1[4]={2301};
int?s2[4]={6745};
for(i=0;i {
// cout< n=n*16+num[s1[i]];
}
for(i=0;i {
// cout< m=m*16+num[s2[i]];
}
//m_fileHdr->bfReserved1=25960;
//m_fileHdr->bfReserved2=27756;
m_fileHdr->bfReserved1=n;
m_fileHdr->bfReserved2=m;
m_fileHdr->bfSize=122;
return?true;
}
bool?BMP::headhideBMP1()?//判斷頭文件有無隱寫
{
//cout<bfReserved1<<“???“<bfReserved2< if(m_fileHdr->bfReserved1==0&&m_fileHdr->bfReserved2==0)
{
cout<<“圖像頭文件冗余無隱寫“< }
else
cout<<“圖像頭文件冗余有隱寫“< return?true;
}
bool?BMP::hideString2BMP(char?*szStr2Hide)?//數(shù)據(jù)區(qū)隱寫
{
m_fileHdr->bfReserved1;
LPBYTE?pAlpha?=?pBuf?+?m_fileHdr->bfOffBits?+?4; //第一個像素的通道位置
int?nHide; //字節(jié)數(shù)
for?(nHide?=?0;?(pAlpha?-?pBuf)?bfSize?&&?szStr2Hide[nHide]?!=?0;?nHide
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????673999??2019-04-06?16:31??Steganography\123.bmp
?????文件?????673974??2019-04-06?16:31??Steganography\123.bmp.hide.bmp
?????文件?????692396??2019-04-07?15:53??Steganography\12_2.bmp
?????文件?????692371??2019-04-07?14:32??Steganography\12_2.bmp.hide.bmp
?????文件?????692391??2019-04-07?15:53??Steganography\12_2.bmp.yuan.bmp
?????文件????3102786??2019-04-07?20:05??Steganography\4_1.bmp
?????文件????3102783??2019-04-07?20:05??Steganography\4_1.bmp.yuan.bmp
?????文件???????4955??2019-04-07?20:21??Steganography\BMP.cpp
?????文件???????1059??2019-04-07?20:09??Steganography\BMP.h
?????文件?????692276??2019-04-06?13:23??Steganography\Debug\12_2.bmp
?????文件?????692271??2019-04-06?13:23??Steganography\Debug\12_2.bmp.hide.bmp
?????文件?????182811??2019-04-07?20:20??Steganography\Debug\BMP.obj
?????文件?????205305??2019-04-07?20:11??Steganography\Debug\Interface.obj
?????文件??????65046??2019-04-07?20:11??Steganography\Debug\StdAfx.obj
?????文件?????589905??2019-04-07?20:20??Steganography\Debug\Steganography.exe
?????文件?????854976??2019-04-07?20:20??Steganography\Debug\Steganography.ilk
?????文件???????5557??2019-04-07?20:11??Steganography\Debug\Steganography.obj
?????文件????4009928??2019-04-07?20:11??Steganography\Debug\Steganography.pch
?????文件????1475584??2019-04-07?20:20??Steganography\Debug\Steganography.pdb
?????文件?????148480??2019-04-07?20:20??Steganography\Debug\vc60.idb
?????文件?????266240??2019-04-07?20:20??Steganography\Debug\vc60.pdb
?????文件???????4529??2019-04-07?20:08??Steganography\Interface.cpp
?????文件????????747??2019-04-06?16:08??Steganography\Interface.h
?????文件???????1250??2019-04-06?12:22??Steganography\ReadMe.txt
?????文件????????361??2019-04-06?12:25??Steganography\StdAfx.cpp
?????文件????????785??2019-04-06?13:32??Steganography\StdAfx.h
?????文件????????210??2019-04-07?15:53??Steganography\Steganography.cpp
?????文件???????4868??2019-04-06?13:54??Steganography\Steganography.dsp
?????文件????????534??2019-04-06?12:22??Steganography\Steganography.dsw
?????文件??????58368??2019-04-07?21:25??Steganography\Steganography.ncb
............此處省略9個文件信息
- 上一篇:服裝網(wǎng)上購物商城源代碼
- 下一篇:Tecplot流體模擬軟件
評論
共有 條評論