0

My question is very closely linked to this one but it has a slightly different tilt to it.

I have a program that reads files of varying size for various reasons. The source files could be 20Kb or 20Mb or 20Gb. A user has asked me to add Base64 support, such that my program analyses the DECODED version of the Base64 file, just like it would a normal file. But the user doesn't want to decode the files himself.

I use Lazarus and Freepascal. I am aware of the TBase64DecodingStream and TBase64EncodingStream and I also found this solution by Engkin in the forum. However, all the examples don't quite explain how to take a Base64 ENCODED file as a stream and generate a Base64 DEcoded version of it. They all seem to relate to encoding and decoding of strings, or creating Base64 ENcoded files. Not creating Base64 DEcoded files from Base64 ENcoded files, which is what I need.

I wonder if any of you could help me? David Heffernan clearly has a good understanding of all things Delphi and Pascal and indeed Base64, but I don't know if he will see this.

Other similar questions are this one but it relates to Javascript for the decoding aspect (though Delphi does feature in it) and also this Java related question

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Gizmo_the_Great
  • 979
  • 13
  • 28
  • I did find your other answer David but unless I mis understand it, it outputs decoded strings but not files. – Gizmo_the_Great Jul 20 '17 at 13:17
  • 2
    No, it works on streams. The examples happen to use string streams, but you can use whatever form of stream you please. Note that base64 encoding converts binary to text. Decoding converts text to binary. – David Heffernan Jul 20 '17 at 13:21
  • Thankyou David! Yes, simply converting the TTStringStreams to TFileStreams, marking my input file as the input TFileStream for EncodedStream, and a temporary output file as the value for TFileStream DecodedStream and it works perfectly! I didn't realise. So thanks. – Gizmo_the_Great Jul 20 '17 at 15:06

0 Answers0