3

I am making a builder/stub application. The builder is coded in XE2 while the stub is coded in Delphi 7.

In XE2 when I use "EncdDecd" it has functions to encode EncodeBase64 and DecodeBase64. But in Delphi 7 when I use EncdDecd it does not have the DecodeBase64 function that I need.

In my builder I am loading a file into a stream and encoding it to a B64 AnsiString and adding it to the resources of the stub. The goal is to have the stub decode this B64 AnsiString into a byte array and ultimately write it to a file on the disk.

3
  • 1
    See this link: Synopse forum:Low level and performance» Very fast asm-implementation of Base64 Encoding/Decoding. Commented Aug 3, 2012 at 6:47
  • 1
    Why base64? That's a very inefficient way to store binary data. I'd compress it with a zlib stream. You use base64 when you need to store/transmit as plain ascii text. Commented Aug 3, 2012 at 7:53
  • 2
    To answer the question that you asked, you can simply use DecodeString and then treat the string return value as a byte array. But base64 still feels like the wrong solution. Commented Aug 3, 2012 at 8:30

2 Answers 2

2

All versions of Delphi from v6 onward ship with Indy preinstalled. Its IdCoderMIME unit has TIdEncoderMIME and TIdDecoderMIME classes for encoding/decoding base64 content.

Sign up to request clarification or add additional context in comments.

3 Comments

Why would Indy be better than EncdDecd unit? Wouldn't it be easier to keep Indy out of this. Seems over the top to introduce Indy just to do base64.
The same can be said of the EncdDecd unit. It is not a standalone unit, and it is not part of the standard RTL. It is part of the Soap package instead. So you have to add a Soap dependancy to the project in order to use that unit. Base64 is such a trivial algorithm, it would make more sense to just implement it manually instead of depending on any 3rd-party code at all.
Well, I agree with that if you are using runtime packages. However, if you are linking statically then EncdDecd is standalone. It has dependency on Classes, SysUtils and RTLConsts.
0

There is plenty of base64 free Delphi code that you can use. TurboPower LockBox 3 also has an implementation of base64. This is compilable in Delphi 7.

8 Comments

That's grossly over the top. The built in EncdDecd unit does base64. Why on earth would you bring in LockBox?!
The OP can just rip out the unit he wants. And anyway, the statement was just to support, as an example, that the code for base64 is in many places and available from many sources.
But why? The necessary code is already in Delphi 7 RTL. Why not just use that?
My interpretation of the OP is that he is saying the decrypt function is not present in Delphi 7. I haven't confirmed this. I am just taking his word on it.
Decrypt function is there. I said so in my comments. Problem is it's not in the form he wants. He wants TBytes returned but it decodes to either stream or string in D7. Trivial to adapt it to his needs.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.