Feature request: protected string contents in external file

Post here any topics that related to Enigma Protector, its functionality, your misunderstanding, offers to improvements etc etc etc
Post Reply
iaanus
Posts: 24
Joined: Tue Feb 03, 2009 12:08 pm

Feature request: protected string contents in external file

Post by iaanus »

Hi,

currently, in order to set the contents of a protected string you either enter the string into the Enigma IDE or load the data from an external file. In both cases the string contents are going to be written in the Enigma project file itself. In a project of mine, I have a 3Kb string that is periodically updated with a text editor. Each time the string changes, I have to remember to update the Enigma project file (actually two different projects). I could easily write an automated script for this, but I am putting on my wish list a feature to have the string contents stored in the file external to the Enigma project file. The project will thus contain only the path name of the external file and Enigma shall read the file contents each time.

Would that be feasible?

Thanks in advance,
Enigma
Site Admin
Posts: 2945
Joined: Wed Aug 20, 2008 2:24 pm

Re: Feature request: protected string contents in external f

Post by Enigma »

Hi iaanus,

I can just advise you another workaround. What if you will use not a Protected Strings feature, but just Virtual Box feature with the option "Never Write to Disk". And when you will need the string - you will just load it from the file.

Or, another solution. Seems you run the protector from a batch, so you may write a simple program, that reads your external file and modifies project .enigma file (modifies the string content according to the content of external file).
iaanus
Posts: 24
Joined: Tue Feb 03, 2009 12:08 pm

Re: Feature request: protected string contents in external f

Post by iaanus »

Yes, creating a script that automatically updates the enigma project is an option. However, the strings seems to be encoded in the XML file and I couldn't determine the algorithm. The <Type> is 2, which I assume corresponds to binary. I'd rather not use regular (non-binary) strings, as the file contains UNIX newlines and special characters that must not be messed with.

I will consider using the virtual box. Just a question: if my exe loads a dll and it's the dll that opens and reads from the file, will it work?
iaanus
Posts: 24
Joined: Tue Feb 03, 2009 12:08 pm

Re: Feature request: protected string contents in external f

Post by iaanus »

iaanus wrote:However, the strings seems to be encoded in the XML file and I couldn't determine the algorithm.
Looks like base64. Is it correct?
Enigma
Site Admin
Posts: 2945
Joined: Wed Aug 20, 2008 2:24 pm

Re: Feature request: protected string contents in external f

Post by Enigma »

iaanus wrote:I will consider using the virtual box. Just a question: if my exe loads a dll and it's the dll that opens and reads from the file, will it work?
Sure, it will work!
iaanus wrote:Looks like base64. Is it correct?
Yes, it is standard base64 encoding!

There is Delphi code of the buffer encryption routine, you may use it:

Code: Select all

const
  // These characters are used when generating BASE64 chars from buffer data
  cBase64Char: array[0..63] of char =
    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  cBase64PadChar: char = '=';

function EncodeBase64Buf(const Buffer; Count: Integer): string;
var
  i, j: integer;
  ACore: integer;
  ALong: cardinal;
  S: PByte;
begin
  // Make sure ASize is always a multiple of 3, and this multiple
  // gets saved as 4 characters
  ACore := (Count + 2) div 3;

  // Set the length of the string that stores encoded characters
  SetLength(Result, ACore * 4);
  S := @Buffer;
  // Do the loop ACore times
  for i := 0 to ACore - 1 do begin
    ALong := 0;
    for j := 0 to 2 do begin
      ALong := ALong shl 8 + S^;
      inc(S);
    end;
    for j := 0 to 3 do begin
      Result[i * 4 + 4 - j] := cBase64Char[ALong and $3F];
      ALong := ALong shr 6;
    end;
  end;
  // For comformity to Base64, we must pad the data instead of zero out
  // if the size is not an exact multiple of 3
  case ACore * 3 - Count of
  0:;// nothing to do
  1: // pad one byte
    Result[ACore * 4] := cBase64PadChar;
  2: // pad two bytes
    begin
      Result[ACore * 4    ] := cBase64PadChar;
      Result[ACore * 4 - 1] := cBase64PadChar;
    end;
  end;//case
end;
iaanus
Posts: 24
Joined: Tue Feb 03, 2009 12:08 pm

Re: Feature request: protected string contents in external f

Post by iaanus »

Enigma wrote:
iaanus wrote:I will consider using the virtual box. Just a question: if my exe loads a dll and it's the dll that opens and reads from the file, will it work?
Sure, it will work!
Wow, that's a truly amazing feature! Kudos for Enigma!
Enigma wrote:
iaanus wrote:Looks like base64. Is it correct?
Yes, it is standard base64 encoding!

There is Delphi code of the buffer encryption routine, you may use it:
Thanks! Actually I prefer scripting in Python where getting a base64 encoded string is as simple as writing:

Code: Select all

   plain = "/*your text here*/
   encoded = plain.encode("base64").strip()
(strip() is needed because Python ends base64 strings with a newline, I don't know why). Python rocks! :)
Enigma
Site Admin
Posts: 2945
Joined: Wed Aug 20, 2008 2:24 pm

Re: Feature request: protected string contents in external f

Post by Enigma »

iaanus wrote:(strip() is needed because Python ends base64 strings with a newline, I don't know why). Python rocks!
Yeap, for scripting work it really rocks :) agree!
Post Reply