Protected Strings strange behavior

Post here messages if you have any problems with working of Enigma Protector
Post Reply
ggpnet
Posts: 13
Joined: Sat Jun 16, 2012 8:00 am

Protected Strings strange behavior

Post by ggpnet »

Good Day and Happy new Year

I'd like to know why when I extract Protected Strings with Enigma_IDE.cs at the end of strings appears a strange character.

Protected Strings - Enigma Protector

Image


Extracted Protected Strings

Image


with Examples - Protected Strings

Code: Select all

private void Form1_Shown(object sender, EventArgs e)
        {
            Int32 len = Enigma_IDE.EP_ProtectedStringByKey("fyi6z02Y", null, 0);
            if (len > 0)
            {
                StringBuilder str = new StringBuilder(len);
                if (Enigma_IDE.EP_ProtectedStringByKey("fyi6z02Y", str, len) > 0)
                {
                    textBox1.Text = str.ToString();                    
                }
            }

            len = Enigma_IDE.EP_ProtectedStringByID(1, null, 0);
            if (len > 0)
            {
                StringBuilder str = new StringBuilder(len);
                if (Enigma_IDE.EP_ProtectedStringByID(1, str, len) > 0)
                {
                    textBox2.Text = str.ToString();
                }
            }

            len = Enigma_IDE.EP_ProtectedStringByKey("26Lu66Er", null, 0);
            if (len > 0)
            {
                StringBuilder str = new StringBuilder(len);
                if (Enigma_IDE.EP_ProtectedStringByKey("26Lu66Er", str, len) > 0)
                {
                    textBox3.Text = str.ToString();
                }
            }
        }

Regards,
Gianfranco
Attachments
Grid.png
Grid.png (5.32 KiB) Viewed 8153 times
Form.png
Form.png (17.21 KiB) Viewed 8153 times
Enigma
Site Admin
Posts: 3085
Joined: Wed Aug 20, 2008 2:24 pm

Re: Protected Strings strange behavior

Post by Enigma »

Hi ggpnet, Happy New Year for you too!

I guess there is something wrong with the C# example. StringBuilder that is used there to extract the protected string requires a null terminated character in the end of the string, that is not inserting by a protection. Protection returns just a buffer with the string, and it does not cares about null terminators and so.

Take a look at the attachment, there is a new example how to extract protected strings, and few helper functions in Enigma_ide.cs file that allows to extract protected strings very easy.
It will be working well.
Attachments
Enigma_IDE.zip
(5.43 KiB) Downloaded 898 times
C# (.NET).ZIP
(9.95 KiB) Downloaded 896 times
Post Reply