| 发表于:2008-01-13 11:50:432楼 得分:0 |
你这个是加了密的。用的是base64加密方式 代码如下: function base64encode(const s: string): string; var i,c1,c2,c3: integer; m,n: integer; const base64: string = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/'; begin result := ''; m:=1; n:=0; for i := 1 to (length(s) div 3) do begin c1 := ord(s[m]); c2 := ord(s[m+1]); c3 := ord(s[m+2]); m:=m+3; result := result+base64[(c1 shr 2)and $3f+1]; result := result+base64[((c1 shl 4)and $30) or ((c2 shr 4)and $0f)+1]; result := result+base64[((c2 shl 2)and $3c) or ((c3 shr 6)and $03)+1]; result := result+base64[c3 and $3f+1]; n:=n+4; if(n = 76)then begin n:=0; result := result+#13#10; end; end; if (length(s) mod 3)=1 then begin c1 := ord(s[m]); result := result+base64[(c1 shr 2)and $3f+1]; result := result+base64[(c1 shl 4)and $30+1]; result := result+'='; result := result+'='; end; if (length(s) mod 3)=2 then begin c1 := ord(s[m]); c2 := ord(s[m+1]); result := result+ base64[(c1 shr 2)and $3f+1]; result := result+ base64[((c1 shl 4)and $30) or ((c2 shr 4)and $0f)+1]; result := result+base64[(c2 shl 2)and $3c+1]; result := result+ '='; end; end; function base64decode(const s: string): string; var i,m,n: integer; c1,c2,c3,c4: integer; const base64: string = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/'; begin result := ''; n:=1; m:=length(s); if s[m]='='then m:=m-1; if s[m]='='then m:=m-1; for i:=1 to m div 4 do begin c1:=pos(s[n],base64)-1; c2:=pos(s[n+1],base64)-1; c3:=pos(s[n+2],base64)-1; c4:=pos(s[n+3],base64)-1; n:=n+4; result:=result+chr(((c1 shl 2)and $fc)or((c2 shr 4)and $3)); result:=result+chr(((c2 shl 4)and $f0)or((c3 shr 2)and $0f)); result:=result+chr(((c3 shl 6)and $c0)or c4); end; if m mod 4=2 then begin c1:=pos(s[n],base64)-1; c2:=pos(s[n+1],base64)-1; result:=result+chr(((c1 shl 2)and $fc)or((c2 shr 4)and $3)); end; if m mod 4=3 then begin c1:=pos(s[n],base64)-1; c2:=pos(s[n+1],base64)-1; c3:=pos(s[n+2],base64)-1; result:=result+chr(((c1 shl 2)and $fc)or((c2 shr 4)and $3)); result:=result+chr(((c2 shl 4)and $f0)or((c3 shr 2)and $0f)); end; end; | | |
|