blob: 5769f94fe4ba1cad840223cddf5494322f6cedca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// base64-encodes data from StdIn and writes the output to StdOut
// (c) 1999 Sebastian Guenther
{$MODE objfpc}
program b64enc;
uses classes, base64, sysutils;
var
b64encoder: TBase64EncodingStream;
InputStream, OutputStream: TStream;
IsEnd: Boolean;
begin
InputStream := THandleStream.Create(StdInputHandle);
OutputStream := THandleStream.Create(StdOutputHandle);
b64encoder := TBase64EncodingStream.Create(OutputStream);
while not IsEnd do
try
b64encoder.WriteByte(InputStream.ReadByte);
except
on e: EStreamError do IsEnd := True;
end;
b64encoder.Free;
InputStream.Free;
OutputStream.Free;
end.
|