Author Topic: Encrypt my DCL file  (Read 7392 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Encrypt my DCL file
« 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.

PKENEWELL

  • Bull Frog
  • Posts: 317
Re: Encrypt my DCL file
« Reply #1 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.
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Encrypt my DCL file
« Reply #2 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

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

PKENEWELL

  • Bull Frog
  • Posts: 317
Re: Encrypt my DCL file
« Reply #3 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!  :-)
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

Coder

  • Swamp Rat
  • Posts: 827
Re: Encrypt my DCL file
« Reply #4 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.

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: Encrypt my DCL file
« Reply #5 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

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: Encrypt my DCL file
« Reply #6 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

Coder

  • Swamp Rat
  • Posts: 827
Re: Encrypt my DCL file
« Reply #7 on: August 07, 2019, 06:19:58 PM »
Thank you Vovka, that helps a lot.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Encrypt my DCL file
« Reply #8 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. 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
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

myloveflyer

  • Newt
  • Posts: 152
Re: Encrypt my DCL file
« Reply #9 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. 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的编码字符串?你能举个例子吗?
« Last Edit: August 07, 2019, 09:33:43 PM by myloveflyer »
Never give up !

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Encrypt my DCL file
« Reply #10 on: August 07, 2019, 09:48:04 PM »
嗨,议员!
如何嵌入表示DCLdef的编码字符串?你能举个例子吗?

在我之前的帖子中,我提供了一个简单示例的链接:链接。希望有所帮助。
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

myloveflyer

  • Newt
  • Posts: 152
Re: Encrypt my DCL file
« Reply #11 on: August 07, 2019, 10:40:36 PM »
嗨,议员!
如何嵌入表示DCLdef的编码字符串?你能举个例子吗?

在我之前的帖子中,我提供了一个简单示例的链接:链接。希望有所帮助。
Thanks,MP
I will go see how to write, don't know how to ask you again.
Never give up !

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Encrypt my DCL file
« Reply #12 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:
  • While I penned this sample using ROT45 I would not use it in production code, too ez to recognize & break.
  • AutoCAD does not need leading white space in dcl files, it's only there to make it ez for the reader to understand.
  • Forgive any mistakes above, been a long day.

Hope this helps, cheers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Encrypt my DCL file
« Reply #13 on: August 07, 2019, 11:55:51 PM »
Glad to see you posting again Michael.  :-) The KungFu is very powerful within you *cheers*.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Encrypt my DCL file
« Reply #14 on: August 08, 2019, 02:27:24 AM »
Far too kind - thanks man! :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Coder

  • Swamp Rat
  • Posts: 827
Re: Encrypt my DCL file
« Reply #15 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.  :-)


Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Encrypt my DCL file
« Reply #16 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
« Last Edit: August 08, 2019, 08:45:21 AM by Grrr1337 »
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

PKENEWELL

  • Bull Frog
  • Posts: 317
Re: Encrypt my DCL file
« Reply #17 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-)
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Encrypt my DCL file
« Reply #18 on: August 08, 2019, 12:36:30 PM »
... erase the temporarily created dcl file right before using the start_dialog function.



Writing and calling dcl on the fly is def the way to go. A simplistic example from days of yore. 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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

PKENEWELL

  • Bull Frog
  • Posts: 317
Re: Encrypt my DCL file
« Reply #19 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. 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
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Encrypt my DCL file
« Reply #20 on: August 08, 2019, 12:54:21 PM »


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. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

PKENEWELL

  • Bull Frog
  • Posts: 317
Re: Encrypt my DCL file
« Reply #21 on: August 08, 2019, 01:35:03 PM »


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. :)

"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Encrypt my DCL file
« Reply #22 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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst