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,
Feature request: protected string contents in external file
Re: Feature request: protected string contents in external f
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).
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).
Re: Feature request: protected string contents in external f
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?
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?
Re: Feature request: protected string contents in external f
Looks like base64. Is it correct?iaanus wrote:However, the strings seems to be encoded in the XML file and I couldn't determine the algorithm.
Re: Feature request: protected string contents in external f
Sure, it will work!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?
Yes, it is standard base64 encoding!iaanus wrote:Looks like base64. Is it correct?
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;
Re: Feature request: protected string contents in external f
Wow, that's a truly amazing feature! Kudos for Enigma!Enigma wrote:Sure, it will work!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?
Thanks! Actually I prefer scripting in Python where getting a base64 encoded string is as simple as writing:Enigma wrote:Yes, it is standard base64 encoding!iaanus wrote:Looks like base64. Is it correct?
There is Delphi code of the buffer encryption routine, you may use it:
Code: Select all
plain = "/*your text here*/
encoded = plain.encode("base64").strip()
Re: Feature request: protected string contents in external f
Yeap, for scripting work it really rocks agree!iaanus wrote:(strip() is needed because Python ends base64 strings with a newline, I don't know why). Python rocks!