当前位置:首页 > 网络编程 > 软件语言 > DELPHI > 简单的文件解码单元

简单的文件解码单元

点击次数:52 次 发布日期:2008-11-09 08:37:48 作者:源代码网
源代码网推荐
广告载入中
uses
源代码网推荐 crt,
源代码网推荐 dos;
源代码网推荐
源代码网推荐 var
源代码网推荐 key:string[8];
源代码网推荐
源代码网推荐 { decode file ---------------------------------------------------------------}
源代码网推荐 {your code here}
源代码网推荐 procedure decode(infname:pathstr);
源代码网推荐 var
源代码网推荐 infile,outfile:file;
源代码网推荐 fdir:dirstr; fname:namestr; fext:extstr;
源代码网推荐 dbuf,sbuf:pointer;
源代码网推荐 idx,i,j,srcseg,srcofs,dstseg,dstofs,start,csize:word;
源代码网推荐 src,rep:byte;
源代码网推荐 begin
源代码网推荐 if maxavail<2*65500 then Begin
源代码网推荐 Writeln(#13#10,"No Memory");
源代码网推荐 halt;
源代码网推荐 End;
源代码网推荐 getmem(dbuf,65500);
源代码网推荐 getmem(sbuf,65500);
源代码网推荐 srcseg:=seg(sbuf^); srcofs:=ofs(sbuf^);
源代码网推荐 dstseg:=seg(dbuf^); dstofs:=ofs(dbuf^); start:=dstofs;
源代码网推荐 assign(infile,infname);
源代码网推荐 {$i-} reset(infile,1); {$i }
源代码网推荐 if ioresult<>0 then Begin
源代码网推荐 Writeln(#13#10"File I/O!");
源代码网推荐 halt;
源代码网推荐 End;
源代码网推荐 if filesize(infile)>65500 then halt;
源代码网推荐 blockread(infile,sbuf^,filesize(infile));
源代码网推荐 csize:=filesize(infile);
源代码网推荐 close(infile);


源代码网推荐 randseed:=ord(key[length(key)]); j:=0;
源代码网推荐 for i:=0 to csize do begin
源代码网推荐 mem[srcseg:srcofs i]:=mem[srcseg:srcofs i] xor
源代码网推荐 (ord(key[j]) random(ord(key[j])));
源代码网推荐 j:=1 j mod 8;
源代码网推荐 end;
源代码网推荐 idx:=0;
源代码网推荐 while idx
源代码网推荐 0 then Begin
源代码网推荐 Writeln(#13#10"Output Error!");
源代码网推荐 halt(4);
源代码网推荐 End;
源代码网推荐 blockwrite(outfile,key[1],length(key)); {so I know which key did it!}
源代码网推荐 blockwrite(outfile,dbuf^,csize); {un encoded}
源代码网推荐 close(outfile);
源代码网推荐 freemem(sbuf,65500);
源代码网推荐 freemem(dbuf,65500);
源代码网推荐 end;
源代码网推荐
源代码网推荐 { main ----------------------------------------------------------------------}
源代码网推荐
源代码网推荐 Procedure ShowFile(FName:String); {just a test ... not used in live version!}
源代码网推荐 Var
源代码网推荐 T:Text;
源代码网推荐 S:String;
源代码网推荐
源代码网推荐 Begin
源代码网推荐 Assign(T,FName);
源代码网推荐 ReSet(T);
源代码网推荐 While not eof(t) do begin
源代码网推荐 {$I-} Readln(t,s); {$I }
源代码网推荐 Writeln(s);
源代码网推荐 End;
源代码网推荐 Close(T);
源代码网推荐 End;
源代码网推荐
源代码网推荐 Var
源代码网推荐 Cnt1:Integer; {character 1}

源代码网推荐 Cnt2:Integer; {2}
源代码网推荐 Cnt3:Integer; {3}
源代码网推荐 Cnt4:Integer; {4}
源代码网推荐 Cnt5:Integer; {5}
源代码网推荐 Cnt6:Integer; {6}
源代码网推荐 Cnt7:Integer; {7}
源代码网推荐 Cnt8:Integer; {8}
源代码网推荐 Ch:Char; {did I press a local key?}
源代码网推荐 outfile:file; {just for making an empty file to append to}
源代码网推荐 Dumb:Byte; {dumb!}
源代码网推荐 done:boolean; {tried from "" to #255#255#255#255#255#255#255#255}
源代码网推荐
源代码网推荐 begin
源代码网推荐 assign(outfile,"hack.org");
源代码网推荐 {$i-} rewrite(outfile,1); {$i }
源代码网推荐 Close(outfile); {made a 0 byte file to append to}
源代码网推荐 {init}
源代码网推荐 Cnt1:=0;
源代码网推荐 Cnt2:=0;
源代码网推荐 Cnt3:=0;
源代码网推荐 Cnt4:=0;
源代码网推荐 Cnt5:=0;
源代码网推荐 Cnt6:=0;
源代码网推荐 Cnt7:=0;
源代码网推荐 Cnt8:=0;
源代码网推荐 done:=false;
源代码网推荐 While not done do begin
源代码网推荐 {not I inc 1 char at a time}
源代码网推荐 Inc(Cnt1);
源代码网推荐 If Cnt1>255 then Begin
源代码网推荐 Cnt1:=0;
源代码网推荐 Inc(Cnt2);
源代码网推荐 End;
源代码网推荐 If Cnt2>255 then Begin
源代码网推荐 Cnt2:=0;
源代码网推荐 Inc(Cnt3);
源代码网推荐 End;
源代码网推荐 If Cnt3>255 then Begin
源代码网推荐 Cnt3:=0;
源代码网推荐 Inc(Cnt4);
源代码网推荐 End;
源代码网推荐 If Cnt4>255 then Begin
源代码网推荐 Cnt4:=0;
源代码网推荐 Inc(Cnt5);
源代码网推荐 End;
源代码网推荐 If Cnt5>255 then Begin
源代码网推荐 Cnt5:=0;
源代码网推荐 Inc(Cnt6);
源代码网推荐 End;
源代码网推荐 If Cnt6>255 then Begin
源代码网推荐 Cnt6:=0;
源代码网推荐 Inc(Cnt7);
源代码网推荐 End;
源代码网推荐 If Cnt7>255 then Begin
源代码网推荐 Cnt7:=0;
源代码网推荐 Inc(Cnt8);
源代码网推荐 End;
源代码网推荐 If Cnt8>255 then Halt;
源代码网推荐 Key:="";
源代码网推荐 If Cnt1<>0 then key:=key chr(cnt1);
源代码网推荐 If Cnt2<>0 then key:=key chr(cnt2);
源代码网推荐 If Cnt3<>0 then key:=key chr(cnt3);
源代码网推荐 If Cnt4<>0 then key:=key chr(cnt4);
源代码网推荐 If Cnt5<>0 then key:=key chr(cnt5);
源代码网推荐 If Cnt6<>0 then key:=key chr(cnt6);
源代码网推荐 If Cnt7<>0 then key:=key chr(cnt7);
源代码网推荐 If Cnt8<>0 then key:=key chr(cnt8);
源代码网推荐 {call your decode method}
源代码网推荐 Decode("HACK.DAT");
源代码网推荐 {ShowFile("HACK.ORG");}


源代码网推荐 {so I can see its running:}
源代码网推荐 Writeln("KEY: ",Key);
源代码网推荐 If Keypressed then Begin
源代码网推荐 Ch:=Readkey;
源代码网推荐 if ch=#27 then halt;
源代码网推荐 End;
源代码网推荐 End;
源代码网推荐 (* if (paramcount<>2) or (pos("?",paramstr(1))>0) then begin
源代码网推荐 writeln("Syntax: DECODE
源代码网推荐
源代码网推荐 ");
源代码网推荐 writeln("Both parameters are required!");
源代码网推荐 halt;
源代码网推荐 end;
源代码网推荐 key:=paramstr(2);
源代码网推荐 decode(paramstr(1));
源代码网推荐 writeln("File successfully decoded!"); *)
源代码网推荐 end.


源代码网推荐

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华