信息隐藏数字水印LSB算法


一种基于LSB算法的,用C语言实现的数字水印方法,简单易懂。
资源截图
代码片段和文件信息
#include
#include
using namespace std;
#define N 100

void Shuiyin()
{
int i;
char name[50];//文件名
int length;//文件长度
char *buf;//文件内容
memset(name 0 50);
cout << “输入要打开的图片:“;
cin >> name;
FILE * f = fopen(name “rb“);//二进制方式
if(!f)
{
cout << “图片“ << name << “打开失败“ << endl;
return;
}
fseek(f0 SEEK_END);//seekend 2 把指针放到末尾
length = ftell(f);//length=文件长度
buf = new char[length + 1];
fseek(f 0 SEEK_SET);
fread(buf length 1 f);
buf[length] = ‘‘;
for(i=501;i<1000;i++)
{
buf[i]=buf[i]&254;
if(i%5==1||i%5==2||i%5==0)
{
buf[i]=buf[i]+1;
}
}
memset(name 0 50);
cout << “输入要保存的文件名:“;
cin >> name;
f = fopen(name “wb“);
if(!f)
{
cout << “保存图片“ << name << “失败“ << endl;
return;
}
cout << “文件“ << name << “保存完毕“ << endl;
fwrite(buf length 1 f);
fclose(f);
}

void Yanzheng()
{
int it=0;
char name[N];//文件名
long length;//文件长度
char *buf;//文件内容
memset(name 0 N);//初始化name
cout << “输入要打开的图片:“;
cin >> name;
FILE * f = fopen(name “rb“);//二进制方式
if(!f)
{
cout << “图片“ << name << “打开失败“ << endl;
return;
}
fseek(f0 SEEK_END);//seekend 2 把指针放到末尾
length = ftell(f);//length=文件长度
cout<<“源文件大小:“< buf = new char[length + 1];
fseek(f 0 SEEK_SET);//把指针放于文件的首部
fread(buf length 1 f);//每一个buf都指向文件
buf[length] = ‘‘;
for(i=501;i<1000;i++)
{
if(i%5==1||i%5==2||i%5==0)
{
if(buf[i]&1)
{
t++;
}
}
else
{
if(buf[i]&1)
{}
else
{
t++;
}
}
}
if(t==499)
{
cout<<“文件完整,未被修改“< }
else
{
cout<<“文件被修改了不完整“< }
fclose(f);
}

void main()
{
int tt=1;
char choice;
while(tt==1)
{
cout< cout<<“   完整性验证  “< cout<<“1、加入水印   “< cout<<“2、验证图像   “< cout<<“3、退出   “< cout<<“请输入你要操作的序列号: “;
cin>>choice;
if(choice==‘1‘)
{
Shuiyin();
}
else if(choice==‘2‘)
{
Yanzheng();
}
else if(choice==‘3‘)
{
cout<<“谢谢使用“;tt=0;break;
}
else
{cout< }
getchar();
system(“pause“);
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      59904  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法Debug数字水印LSB.exe

     文件     691448  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法Debug数字水印LSB.ilk

     文件     756736  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法Debug数字水印LSB.pdb

     文件   15990784  2013-05-23 15:01  C语言信息隐藏数字水印LSB算法ipch数字水印lsb-3d04066b数字水印lsb-c259d0d8.ipch

     文件     900654  2013-04-17 11:24  C语言信息隐藏数字水印LSB算法数字水印LSB2.bmp

     文件     900654  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSB22.bmp

     文件    2070582  2013-04-16 10:41  C语言信息隐藏数字水印LSB算法数字水印LSB3.bmp

     文件     533334  2013-04-17 10:50  C语言信息隐藏数字水印LSB算法数字水印LSB5.bmp

     文件       4402  2012-12-31 11:02  C语言信息隐藏数字水印LSB算法数字水印LSBDebug1.bmp

     文件       4402  2012-12-29 20:53  C语言信息隐藏数字水印LSB算法数字水印LSBDebug11.bmp

     文件        790  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebugcl.command.1.tlog

     文件       9210  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebugCL.read.1.tlog

     文件        548  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebugCL.write.1.tlog

     文件          2  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink-cvtres.read.1.tlog

     文件          2  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink-cvtres.write.1.tlog

     文件          2  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink.1456-cvtres.read.1.tlog

     文件          2  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink.1456-cvtres.write.1.tlog

     文件          2  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink.1456.read.1.tlog

     文件          2  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink.1456.write.1.tlog

     文件          2  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink.2504-cvtres.read.1.tlog

     文件          2  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink.2504-cvtres.write.1.tlog

     文件          2  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink.2504.read.1.tlog

     文件          2  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink.2504.write.1.tlog

     文件       1834  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink.command.1.tlog

     文件       3354  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink.read.1.tlog

     文件       1180  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebuglink.write.1.tlog

     文件      83528  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebugLSB.obj

     文件        460  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebugmt.command.1.tlog

     文件        566  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebugmt.read.1.tlog

     文件        462  2013-05-23 14:25  C语言信息隐藏数字水印LSB算法数字水印LSBDebugmt.write.1.tlog

............此处省略27个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)