//----------------------------------------------------------------------------<br>//base64字符串加密函数<br>function Base64Encode(const s: string): string;<br>var<br> i,c1,c2,c3: Integer;<br> m,n: Integer;<br>const<br> Base64: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';<br>begin<br> Result := '';<br> m:=1;<br> n:=0;<br> for i := 1 to (Length(s) div 3) do<br> begin<br> c1 := Ord(s[m]);<br> c2 := Ord(s[m+1]);<br> c3 := Ord(s[m+2]);<br> m:=m+3;<br> Result := Result+base64[(c1 shr 2)and $3F+1];<br> Result := Result+base64[((c1 shl 4)and $30) or ((c2 shr 4)and $0F)+1];<br> Result := Result+base64[((c2 shl 2)and $3C) or ((c3 shr 6)and $03)+1];<br> Result := Result+base64[c3 and $3F+1];<br> n:=n+4;<br> if(n = 76)then<br> begin<br> n:=0;<br> Result := Result+#13#10;<br> end;<br> end;<br> if (Length(s) mod 3)=1 then<br> begin<br> c1 := Ord(s[m]);<br> Result := Result+base64[(c1 shr 2)and $3F+1];<br> Result := Result+base64[(c1 shl 4)and $30+1];<br> Result := Result+'=';<br> Result := Result+'=';<br> end;<br> if (Length(s) mod 3)=2 then<br> begin<br> c1 := Ord(s[m]);<br> c2 := Ord(s[m+1]);<br> Result := Result+ base64[(c1 shr 2)and $3F+1];<br> Result := Result+ base64[((c1 shl 4)and $30) or ((c2 shr 4)and $0F)+1];<br> Result := Result+base64[(c2 shl 2)and $3C+1];<br> Result := Result+ '=';<br> end;<br>end;<br>//----------------------------------------------------------------------------<br>//base64字符串解密函数<br>function Base64Decode(const s: string): string;<br>var<br> i,m,n: Integer;<br> c1,c2,c3,c4: Integer;<br>const<br> Base64: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';<br>begin<br> Result := '';<br> n:=1;<br> m:=Length(s);<br> if s[m]='='then m:=m-1;<br> if s[m]='='then m:=m-1;<br> for i:=1 to m div 4 do<br> begin<br> c1:=Pos(s[n],Base64)-1;<br> c2:=Pos(s[n+1],Base64)-1;<br> c3:=Pos(s[n+2],Base64)-1;<br> c4:=Pos(s[n+3],Base64)-1;<br> n:=n+4;<br> Result:=Result+Chr(((c1 shl 2)and $FC)or((c2 shr 4)and $3));<br> Result:=Result+Chr(((c2 shl 4)and $F0)or((c3 shr 2)and $0F));<br> Result:=Result+Chr(((c3 shl 6)and $C0)or c4);<br> end;<br> if m mod 4=2 then<br> begin<br> c1:=Pos(s[n],Base64)-1;<br> c2:=Pos(s[n+1],Base64)-1;<br> Result:=Result+Chr(((c1 shl 2)and $FC)or((c2 shr 4)and $3));<br> end;<br><br> if m mod 4=3 then<br> begin<br> c1:=Pos(s[n],Base64)-1;<br> c2:=Pos(s[n+1],Base64)-1;<br> c3:=Pos(s[n+2],Base64)-1;<br> Result:=Result+Chr(((c1 shl 2)and $FC)or((c2 shr 4)and $3));<br> Result:=Result+Chr(((c2 shl 4)and $F0)or((c3 shr 2)and $0F));<br> end;<br>end;<br><br><br>分全部给我吧,我没分了.