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