How to encode file of any type into base64 string and then decode it into file again using Lazarus/Delphi?
问题 Can you tell me how can I do that? Is there any Freepascal unit that can do this for me? I need that so my program can store binary data in it's XML-based fileformat. 回答1: Use the base64 unit and its two classes, TBase64EncodingStream and TBase64DecodingStream . Here is a simple example: program demo; uses Classes, base64; var DecodedStream: TStringStream; EncodedStream: TStringStream; Encoder: TBase64EncodingStream; Output: string; begin DecodedStream := TStringStream.Create('Hello World!');