Declaration: DecodeBase64 (InStream, OutStream: TStream): integer;
The function DecodeBase64 decodes the base-64 encoded data stream InStream and writes the result to the stream OutStream. Data of Instream is read from the current stream position; the resulting decoded data is written to the current position of Outstream (overwriting all data after the current position).

The function returns the following error codes:

 0 ... no error
-1 ... invalid character in the input stream

In addition to the original definition DecodeBase64 accepts CR (ASCII 13) and LF (ASCII 10) in the input stream. These characters are discarded during the decoding process.