+ New example for base64 encoding

This commit is contained in:
michael 2004-07-14 07:22:33 +00:00
parent 072f6e4ec6
commit c7c5594bcd

39
fcl/tests/b64.pp Normal file
View File

@ -0,0 +1,39 @@
{$mode objfpc}
{$h+}
program b64;
uses classes,base64;
Function EncodeBase64(S : String) : String;
Var
S1,S2 : TStringStream;
begin
S1:=TStringStream.Create(S);
Try
S1.Position:=0;
S2:=TStringStream.Create('');
Try
With TBase64EncodingStream.Create(S2) do
Try
CopyFrom(S1,S1.Size);
Finally
Free;
end;
Result:=S2.DataString;
finally
S2.Free;
end;
finally
S1.Free;
end;
end;
Var
S : String;
begin
S:='String to be encoded';
Writeln('"',S,'" -> "',EncodeBase64(S),'"');
end.