TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Coder on August 07, 2019, 03:44:06 PM

Title: Encrypt my DCL file
Post by: Coder on August 07, 2019, 03:44:06 PM
Hello guys,

Is there a way to encrypt a DCL file ?
Else I am trying to add the DCL with the lisp file in a VLX but it seems that it does not work because the DCL can't be found !

Any ideas?

Thank you.
Title: Re: Encrypt my DCL file
Post by: PKENEWELL on August 07, 2019, 04:22:22 PM
I don't know of a way to encrypt a DCL file. Also I don't know if the DCL in a VLX file works properly or if there is something special that must be done to make it work.

here are 2 alternative options:

1) have the lisp program write the dcl file on the fly before loading it, then delete the DCL after the program has run (done this way by many in this group). or,

2) Use a 3rd party DCL replacement such as OpenDCL or ObjectDCL.

Hope this helps.
Title: Re: Encrypt my DCL file
Post by: ronjonp on August 07, 2019, 04:22:48 PM
Vovka will probably chime in but yes it can be done. Look at the thread here: http://www.theswamp.org/index.php?topic=47908.0
Title: Re: Encrypt my DCL file
Post by: PKENEWELL on August 07, 2019, 04:24:51 PM
Yes - If vovka could chime in, I would be interested i how that is done as well!  :-)
Title: Re: Encrypt my DCL file
Post by: Coder on August 07, 2019, 04:45:09 PM
Thank you guys for your replies.

I am glad that it is possible and hope that Mr. Vovka would help in this regard.
Title: Re: Encrypt my DCL file
Post by: VovKa on August 07, 2019, 06:09:40 PM
dcl-s work fine within vlx containers
never had a single problem

i have only one suggestion:
LOAD_DIALOG's argument should not include a full path, only a file name

the latest versions of my program build dcl on the fly
the main reason was - localization
it is easier to build a dcl according to a template than keeping a separate dialog for every language
Title: Re: Encrypt my DCL file
Post by: VovKa on August 07, 2019, 06:13:04 PM
i have to add:
dcl-s are not encrypted inside vlx-s, they are just plain texts and can be view by any viewer
Title: Re: Encrypt my DCL file
Post by: Coder on August 07, 2019, 06:19:58 PM
Thank you Vovka, that helps a lot.
Title: Re: Encrypt my DCL file
Post by: MP on August 07, 2019, 06:25:47 PM
Writing and calling dcl on the fly is def the way to go. A simplistic example from days of yore (http://www.theswamp.org/index.php?topic=10028.msg128497#msg128497). If security is an issue you can embed encoded strings representing the dcl def (vl-string-translate can be used to create a simple cypher/de-cypher), decoding them before creating the dcl file and then delete the temp dcl file as soon as it's loaded into memory. EZPZ
Title: Re: Encrypt my DCL file
Post by: myloveflyer on August 07, 2019, 09:23:17 PM
Writing and calling dcl on the fly is def the way to go. A simplistic example from days of yore (http://www.theswamp.org/index.php?topic=10028.msg128497#msg128497). If security is an issue you can embed encoded strings representing the dcl def (vl-string-translate can be used to create a simple cypher/de-cypher), decoding them before creating the dcl file and then delete the temp dcl file as soon as it's loaded into memory. EZPZ
嗨,议员!
如何嵌入表示DCLdef的编码字符串?你能举个例子吗?
Title: Re: Encrypt my DCL file
Post by: MP on August 07, 2019, 09:48:04 PM
嗨,议员!
如何嵌入表示DCLdef的编码字符串?你能举个例子吗?

在我之前的帖子中,我提供了一个简单示例的链接:链接 (http://www.theswamp.org/index.php?topic=10028.msg128497#msg128497)。希望有所帮助。
Title: Re: Encrypt my DCL file
Post by: myloveflyer on August 07, 2019, 10:40:36 PM
嗨,议员!
如何嵌入表示DCLdef的编码字符串?你能举个例子吗?

在我之前的帖子中,我提供了一个简单示例的链接:链接 (http://www.theswamp.org/index.php?topic=10028.msg128497#msg128497)。希望有所帮助。
Thanks,MP
I will go see how to write, don't know how to ask you again.
Title: Re: Encrypt my DCL file
Post by: MP on August 07, 2019, 10:57:32 PM
To illuminate simple encoding maybe this quick example will help.

This is a mild variation of one of the simplest and oldest encoding schemes, rot13.

Read more here: https://en.wikipedia.org/wiki/ROT13

Code: [Select]
(defun ROT45 ( text )
    (vl-string-translate
        "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~"
        "PQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO"
        text
    )       
)

Example:

    (ROT45 "theswamp.org") >> "E96DH2>A[@C8"

If you run ROT45 on text encoded by ROT45 it returns the original value:

    (ROT45 "E96DH2>A[@C8") >> "theswamp.org"

Or

    (ROT45 (ROT45 "theswamp.org")) >> "theswamp.org"

So let's say this is your naked dcl-def:

Code: [Select]
(setq temp
   '(
        "EdAtt : dialog {"
        "    label = \"Edit Attribute <TagString>\";"
        "    key = \"title\";"
        "    initial_focus = \"text\";"
        "    spacer;"
        "    :   edit_box {"
        "        key = \"text\";"
        "        edit_width = 40;"
        "        edit_limit = 2048;"
        "        allow_accept = true;"
        "    }"
        "    spacer;"
        "    ok_cancel;"
        "    spacer;"
        "}"
    )
)

If we run ROT45 against it (mapcar 'ROT45 temp) we get:

(
    "t5pEE i 5:2=@8 L"
    "    =236= l \"t5:E pEEC:3FE6 k'28&EC:?8m\"j"
    "    <6J l \"E:E=6\"j"
    "    :?:E:2=17@4FD l \"E6IE\"j"
    "    DA246Cj"
    "    i   65:E13@I L"
    "        <6J l \"E6IE\"j"
    "        65:E1H:5E9 l c^j"
    "        65:E1=:>:E l a^cgj"
    "        2==@H12446AE l ECF6j"
    "    N"
    "    DA246Cj"
    "    @<142?46=j"
    "    DA246Cj"
    "N"
)


This encoded string list is what you would place in your source file.

Code: [Select]
(setq dcl-def
   '(
        "t5pEE i 5:2=@8 L"
        "    =236= l \"t5:E pEEC:3FE6 k'28&EC:?8m\"j"
        "    <6J l \"E:E=6\"j"
        "    :?:E:2=17@4FD l \"E6IE\"j"
        "    DA246Cj"
        "    i   65:E13@I L"
        "        <6J l \"E6IE\"j"
        "        65:E1H:5E9 l c^j"
        "        65:E1=:>:E l a^cgj"
        "        2==@H12446AE l ECF6j"
        "    N"
        "    DA246Cj"
        "    @<142?46=j"
        "    DA246Cj"
        "N"
    )
)

When you want to "unpack" it run ROT45 against it (mapcar 'ROT45 dcl-def):

(
    "EdAtt : dialog {"
    "    label = \"Edit Attribute <TagString>\";"
    "    key = \"title\";"
    "    initial_focus = \"text\";"
    "    spacer;"
    "    :   edit_box {"
    "        key = \"text\";"
    "        edit_width = 40;"
    "        edit_limit = 2048;"
    "        allow_accept = true;"
    "    }"
    "    spacer;"
    "    ok_cancel;"
    "    spacer;"
    "}"
)


Notes:

Hope this helps, cheers.
Title: Re: Encrypt my DCL file
Post by: ronjonp on August 07, 2019, 11:55:51 PM
Glad to see you posting again Michael.  :-) The KungFu is very powerful within you *cheers*.
Title: Re: Encrypt my DCL file
Post by: MP on August 08, 2019, 02:27:24 AM
Far too kind - thanks man! :)
Title: Re: Encrypt my DCL file
Post by: Coder on August 08, 2019, 06:59:45 AM
Wow that's too great MP and more than I expected for sure.
Thank you so much for taking the time and giving all these useful examples.

Your ROT45 function looks cool and I think that is the one that I was looking for.

Thanks again and have a great day.  :-)

Title: Re: Encrypt my DCL file
Post by: Grrr1337 on August 08, 2019, 08:41:26 AM
i have to add:
dcl-s are not encrypted inside vlx-s, they are just plain texts and can be view by any viewer

I have the same observation, hence in order to correctly load the .dcl file via the load_dialog function
the DCL code inside should not be encrypted, else one'll get a DCL syntax error.
DCL-on-the-fly + lisp compiling is the way to go, if one sticks to this little detail - erase the temporarily created dcl file right before using the start_dialog function.
Check this -

https://gifyu.com/image/hS0v
Title: Re: Encrypt my DCL file
Post by: PKENEWELL on August 08, 2019, 12:29:59 PM

I have the same observation, hence in order to correctly load the .dcl file via the load_dialog function
the DCL code inside should not be encrypted, else one'll get a DCL syntax error.
DCL-on-the-fly + lisp compiling is the way to go, if one sticks to this little detail - erase the temporarily created dcl file right before using the start_dialog function.
Check this -

https://gifyu.com/image/hS0v

Great Example Grrr1337! It had not occurred to me that you could actually delete the DCL file between the calls to "load_dialog" and "start_dialog"! Your KungFu is very strong!  8-)
Title: Re: Encrypt my DCL file
Post by: MP on August 08, 2019, 12:36:30 PM
... erase the temporarily created dcl file right before using the start_dialog function.

(http://theswamp.org/screens/mp/thumbsup.gif)

Writing and calling dcl on the fly is def the way to go. A simplistic example from days of yore (http://www.theswamp.org/index.php?topic=10028.msg128497#msg128497). If security is an issue you can embed encoded strings representing the dcl def (vl-string-translate can be used to create a simple cypher/de-cypher), decoding them before creating the dcl file and then delete the temp dcl file as soon as it's loaded into memory.
Title: Re: Encrypt my DCL file
Post by: PKENEWELL on August 08, 2019, 12:43:57 PM
Writing and calling dcl on the fly is def the way to go. A simplistic example from days of yore (http://www.theswamp.org/index.php?topic=10028.msg128497#msg128497). If security is an issue you can embed encoded strings representing the dcl def (vl-string-translate can be used to create a simple cypher/de-cypher), decoding them before creating the dcl file and then delete the temp dcl file as soon as it's loaded into memory.

Well - can't leave you out MP! You are a Master!  :-D
Title: Re: Encrypt my DCL file
Post by: MP on August 08, 2019, 12:54:21 PM
(http://www.geek.com/wp-content/uploads/2014/04/steve-jobs-head.jpg)

Just because the normal convention is to use the file extensions of .lsp and .dcl for lisp and dcl files respectively does not mean you have to - you can use your own extensions, further adding a level of obfuscation. Try it.

@ PK. :)
Title: Re: Encrypt my DCL file
Post by: PKENEWELL on August 08, 2019, 01:35:03 PM
(http://www.geek.com/wp-content/uploads/2014/04/steve-jobs-head.jpg)

Just because the normal convention is to use the file extensions of .lsp and .dcl for lisp and dcl files respectively does not mean you have to - you can use your own extensions, further adding a level of obfuscation. Try it.

@ PK. :)

(http://www.marieluisesmith.com/wp-content/uploads/2016/07/tumblr_inline_nv063aNBP81szxb0t_500.gif)
Title: Re: Encrypt my DCL file
Post by: MP on August 08, 2019, 03:19:18 PM
Wow that's too great MP and more than I expected for sure.
Thank you so much for taking the time and giving all these useful examples.

Your ROT45 function looks cool and I think that is the one that I was looking for.

Thanks again and have a great day.  :-)

Sorry, I missed this. You're most welome.