恳请各位大虾帮小弟看一下,有那些地方出错了。应该怎么改。拜托了!!
1.加密隐藏原程序:
functionvarargout=Tuxiangjiami(varargin)
gui_Singleton=1;
gui_State=struct('gui_Name',mfilename,...
'gui_Singleton',gui_Singleton,...
'gui_OpeningFcn',@Tuxiangjiami_OpeningFcn,...
'gui_OutputFcn',@Tuxiangjiami_OutputFcn,...
'gui_LayoutFcn',[],...
'gui_Callback',[]);
if nargin&isstr(varargin{1})
gui_State.gui_Callback=str2func(varargin{1});
end
if nargout
[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});
else
gui_mainfcn(gui_State,varargin{:});
end
functionTuxiangjiami_OpeningFcn(hObject,eventdata,handles,varargin)
handles.output=hObject;
guidata(hObject,handles);
functionvarargout=Tuxiangjiami_OutputFcn(hObject,eventdata,handles)
arargout{1}=handles.output;
functionpushbutton1_Callback(hObject,eventdata,handles)
globalcounter
globalyasuobina
[filename1,pathname]=uigetfile('*.jpg','Openfile...');
fid1=fopen([pathnamefilename1],'rb');
yasuoa=fread(fid1,inf,'uint8');%二进制读入
fid2=fopen('temp1.jpg','w+');%新建一个空白图
fwrite(fid2,yasuoa,'uint8');%写入读入的二进制代码
imshow(imread('temp1.jpg'))%读出它的RGB并画图
yasuobina=dec2bin(yasuoa);
[binarow,binclounm]=size(yasuobina);
counter=binarow*binclounm;%计算压缩的二进制的总位数
functionpushbutton2_Callback(hObject,eventdata,handles)
globala
globalb
[filename2,pathname]=uigetfile('*.jpg','Openfile...');
a=imread([pathname,filename2]);%a为载体图象
imwrite(a,'temp2','bmp');
b=imread('temp2','bmp');
imshow(b);
ffunctionpushbutton3_Callback(hObject,eventdata,handles)
globalb
globalcounter
globalyasuobina
globalcounter
ad=double(b);
[adrow,adcolumn]=size(ad);
number=adrow*adcolumn;%计算a元素各数
onearraybin=dec2bin(ad);
[binprow,binpclounm]=size(onearraybin);
range=binprow*binpclounm;
miyao=counter/8;
miyaobin=dec2bin(miyao);
[miyaorow,miyaocolunm]=size(miyaobin);
fori=1:miyaocolunm
onearraybin(range+1-i)=miyaobin(miyaocolunm-i+1);
end
fori=(miyaocolunm+1):30
onearraybin(range+1-i)=''''0'''';
end
fori=31:(counter+30)
onearraybin(range+1-i)=yasuobina(i-30);
end
onearray=bin2dec(onearraybin);
new=ones(adrow,adcolumn/3,3);
fork=1:3
forj=1:(adcolumn/3)
fori=1:adrow
new(i,j,k)=onearray(i+(j-1)*adrow+(k-1)*adrow*adcolumn/3);
end
end
end
c=uint8(new);
imshow(c)
imwrite(c,'hide.bmp','bmp')
msgbox(['操作成功!密钥为:'miyaostr'请切记!!!'],'Message');
2.解密提取原程序:
functionvarargout=Tuxiangjiemi(varargin)
gui_Singleton=1;
gui_State=struct('gui_Name',mfilename,...
'gui_Singleton',gui_Singleton,...
'gui_OpeningFcn',@Tuxiangjiemi_OpeningFcn,...
'gui_OutputFcn',@Tuxiangjiemi_OutputFcn,...
'gui_LayoutFcn',[],...
'gui_Callback',[]);
ifnargin&isstr(varargin{1})
gui_State.gui_Callback=str2func(varargin{1});
end
ifnargout
[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});
else
gui_mainfcn(gui_State,varargin{:});
end
functionTuxiangjiemi_OpeningFcn(hObject,eventdata,handles,varargin)
handles.output=hObject;
guidata(hObject,handles);
functionvarargout=Tuxiangjiemi_OutputFcn(hObject,eventdata,handles)
varargout{1}=handles.output;
functionpushbutton1_Callback(hObject,eventdata,handles)
globalyitiao
[filename1,pathname]=uigetfile('*.bmp','Openfile...');
yitiao=imread([pathname,filename1],'bmp');
imshow(yitiao)
functionedit1_CreateFcn(hObject,eventdata,handles)
ifispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
functionpushbutton2_Callback(hObject,eventdata,handles)
globalyitiao
globalmiyao
miyao=0;
msuc=0;
prompt={'请输入密钥:'};
dlgTitle='输入密钥';
lineNo=1;
field={'num'};miyao=inputdlg(prompt,dlgTitle,lineNo)
[此贴子已经被作者于2006-5-13 10:20:04编辑过]