OpenDCL Forums

OpenDCL => Studio/Dialog Editor => Topic started by: Emiliano on July 11, 2012, 02:10:25 AM

Title: Protect the project. Odcl with a password
Post by: Emiliano on July 11, 2012, 02:10:25 AM
Hello everyone,
I use OpenDCL with Bricscad V12

I would love, protect the project. Odcl with a password so other users can not modify it.
I tried using the command Project-> Set Password Project, but after saving the file, it opens quietly in OpenDCL Studio without requiring a password.

Can you help me understand how it works?
Thanks in advance
Title: Re: Protect the project. Odcl with a password
Post by: roy_043 on July 11, 2012, 09:15:13 AM
The password does not protect the ODCL file itself. However, if a password protected project has been loaded in the CAD-program the password is required for the (Project_Export) function. This prevents an embedded ODCL project from being accessed by unauthorized users.
Title: Re: Protect the project. Odcl with a password
Post by: Emiliano on July 11, 2012, 09:22:33 AM
Ok,
it is now clear.
According to me it would be best, however, can also enter a password to the file. Odcl

Pity that you can not do. :'(
Title: Re: Protect the project. Odcl with a password
Post by: owenwengerd on July 11, 2012, 01:22:28 PM
I am curious what you would do with such a file.
Title: Re: Protect the project. Odcl with a password
Post by: Emiliano on July 11, 2012, 09:55:01 PM
I realized very complicated dialog boxes, with attractive graphics.
It took me many hours of work.
I'm sorry that another developer can copy my work.
Even the GUI should be as important as the code behind.
Title: Re: Protect the project. Odcl with a password
Post by: roy_043 on July 12, 2012, 12:44:41 AM
That is why you should embed your password protected project in a vlx (Autocad) or des (Bricscad) file.
http://www.opendcl.com/forum/index.php?topic=587.0 (http://www.opendcl.com/forum/index.php?topic=587.0)
http://opendcl.com/wordpress/?page_id=10 (http://opendcl.com/wordpress/?page_id=10) (Beginners Tutorial)

When I compile an ODCL project I save it to a separate base64 textfile which can be created by saving this string:
Code (autolisp) Select
(setq string (dcl_Project_Export project password))
This process can be automated with a simple lisp function.

This textfile is then compiled, together with all other project files, into a single des file (or vlx file if you use AC).
For a project called "projectname" with a base64 file called "projectname_base64.txt" I use this code to load the ODCL project:
Code (autolisp) Select

(if
  (not
    (or
      (dcl_Project_Import (vl-get-resource "projectname_base64"))
      (dcl_Project_Load "projectname" 'T)
    )
  )
  (progn
    (princ "\nError: odcl dialog not found ")
    (exit)
  )
)

Title: Re: Protect the project. Odcl with a password
Post by: owenwengerd on July 12, 2012, 03:27:46 AM
Quote from: Emiliano on July 11, 2012, 09:55:01 PM
I realized very complicated dialog boxes, with attractive graphics.
It took me many hours of work.
I'm sorry that another developer can copy my work.
Even the GUI should be as important as the code behind.

Please answer my question. What would you do with a password protected .odcl file like you described?
Title: Re: Protect the project. Odcl with a password
Post by: Emiliano on July 12, 2012, 09:31:39 AM
Quote from: owenwengerd on July 12, 2012, 03:27:46 AM
Please answer my question. What would you do with a password protected .odcl file like you described?

I thought I'd responded to my previous post.
I try to explain better:
I'd like that after you set the password, you can not open the project in Studio OpenDCL without entering the password

It is now more clear?
Title: Re: Protect the project. Odcl with a password
Post by: Emiliano on July 12, 2012, 09:35:24 AM
Quote from: roy_043 on July 12, 2012, 12:44:41 AM
That is why you should embed your password protected project in a vlx (Autocad) or des (Bricscad) file.
http://www.opendcl.com/forum/index.php?topic=587.0 (http://www.opendcl.com/forum/index.php?topic=587.0)
http://opendcl.com/wordpress/?page_id=10 (http://opendcl.com/wordpress/?page_id=10) (Beginners Tutorial)

When I compile an ODCL project I save it to a separate base64 textfile which can be created by saving this string:
Code (autolisp) Select
(setq string (dcl_Project_Export project password))
This process can be automated with a simple lisp function.

This textfile is then compiled, together with all other project files, into a single des file (or vlx file if you use AC).
For a project called "projectname" with a base64 file called "projectname_base64.txt" I use this code to load the ODCL project:
Code (autolisp) Select

(if
  (not
    (or
      (dcl_Project_Import (vl-get-resource "projectname_base64"))
      (dcl_Project_Load "projectname" 'T)
    )
  )
  (progn
    (princ "\nError: odcl dialog not found ")
    (exit)
  )
)



Thanks for your response.
I did not know you could include multiple files into one file. Des.
By the weekend, I make some tests and let you know the outcome.
Title: Re: Protect the project. Odcl with a password
Post by: roy_043 on July 12, 2012, 09:57:38 AM
Please note that you can also put the base64 string (or list-of-strings) in the lisp file itself or in a separate lisp file.
To get a lisp file with a list-of-strings do the following:
ODCL Studio > File > Save as > Supply a filename with the .lsp extension
Check the tutorial I have mentioned for more info.

The method I have described is just the way I prefer to do this. It keeps things nicely separated.

Since there is no need to make the ODCL file available to the public, password-protecting that file is unnecessary.

You can put multiple files (lsp, dcl and txt) inside a single des file.
Title: Re: Protect the project. Odcl with a password
Post by: owenwengerd on July 12, 2012, 10:20:00 AM
Quote from: Emiliano on July 12, 2012, 09:31:39 AM
I'd like that after you set the password, you can not open the project in Studio OpenDCL without entering the password
It is now more clear?

I already understood that. I wanted to know what else you would do with a password protected file. Probably you are missing the purpose of my question due to the language barrier, but I think if you consider it carefully you will understand why your proposal is not practical.
Title: Re: Protect the project. Odcl with a password
Post by: Emiliano on July 14, 2012, 09:38:36 AM
Quote from: owenwengerd on July 12, 2012, 10:20:00 AM
Quote from: Emiliano on July 12, 2012, 09:31:39 AM
I'd like that after you set the password, you can not open the project in Studio OpenDCL without entering the password
It is now more clear?

I already understood that. I wanted to know what else you would do with a password protected file. Probably you are missing the purpose of my question due to the language barrier, but I think if you consider it carefully you will understand why your proposal is not practical.

Hello,
it is true I do not know English very well, but not I seem to find other ways to interpret the question :-(

Can you explain why my proposal is not practical?
I would like a .Odcl file protected by a password that:
- You can not open in OpenDCL Studio
- Of course you can use with the Lisp code by entering a password directly into the file. Lsp then compiled. Des
Title: Re: Protect the project. Odcl with a password
Post by: owenwengerd on July 15, 2012, 09:54:15 AM
If you encrypt the .odcl file so that a password is needed to open it, then you must send the password along with the file. This is the fallacy. You propose to hide the password inside the lisp file, but as you know, it is already easy to hide the entire .odcl file inside the lisp file.
Title: Re: Protect the project. Odcl with a password
Post by: Emiliano on July 15, 2012, 11:05:31 PM
Quote from: owenwengerd on July 15, 2012, 09:54:15 AM
If you encrypt the .odcl file so that a password is needed to open it, then you must send the password along with the file. This is the fallacy. You propose to hide the password inside the lisp file, but as you know, it is already easy to hide the entire .odcl file inside the lisp file.

Maybe I'm missing some step.
I always compiled my individual files *. Lsp in as many individual files *. Des.
I never compiled the project. Odcl: I also compile this with DESCoder?
How can I do to compile all files into one file des?

I have a little confusion ...
Can you clarify?
thanks
Title: Re: Protect the project. Odcl with a password
Post by: roy_043 on July 16, 2012, 02:31:43 AM
Info on the DEScoder (make sure to read the Project Mode section):
http://www.lt-extender.com/LT-Extender/englisch/inhalte/DEScoder/DESCoder.htm (http://www.lt-extender.com/LT-Extender/englisch/inhalte/DEScoder/DESCoder.htm)

You cannot compile an ODCL file into a DES file. But, as explained in this thread, you can create a lsp file or a txt file from your ODCL project. And these files can be compiled into a single DES file.
Title: Re: Protect the project. Odcl with a password
Post by: roy_043 on July 16, 2012, 04:08:11 AM
Attached is a small project showing the use of the base64 text file method described earlier.

These two files:
  BC_Compile_Sample.lsp
  BC_Compile_Sample_Base64.txt
Are compiled into a single des file.
Title: Re: Protect the project. Odcl with a password
Post by: Emiliano on July 16, 2012, 09:20:31 PM
Hello Roy,
thanks for all the information and the example given.
I did not understand the previous post because I used an older version of DESCorder

Now, considering that everything can be compiled into a single file. Des encrypted, the password entry makes no sense, right?
I'd like to avoid using, every time I change something, your function "Create_Base64": is it possible?
I noticed that with OpenDCL Studio can save the project in .Lsp.

So I decided to do the following steps:
1. I renamed the your file "BC_Compile_Sample.lsp" in "Function.lsp"
2. I saved the project "BC_Compile_Sample.odcl" in "BC_Compile_Sample.lsp"
3. I renamed the file "BC_Compile_Sample.odcl" in "BC_Compile_Sample_OLDDDDDD.odcl."
4. I renamed the file "BC_Compile_Sample.lsp" in "BC_Compile_Sample.txt"
5. I compiled the file "BC_Compile_Sample.txt" and the file "Function.lsp" in a single file .Des

Maybe I made a few step too many, but in this way, your example works!
I tried to make the same steps with my project, but it appears the error "Project failed to load! The file coluld not be found or an error occurred while reading the file. [NomePrg]"

What could be the reason for this error?
Thanks in advance
Title: Re: Protect the project. Odcl with a password
Post by: Emiliano on July 16, 2012, 11:18:22 PM
I solved it by removing the line
(dcl_Project_Load "NomePrj" T)


your example worked with the same ...

Now, I have everything on a single file .Des: This is fantastic!  ;D
Thank you!
Title: Re: Protect the project. Odcl with a password
Post by: roy_043 on July 17, 2012, 12:46:09 AM
Quote from: Emiliano on July 16, 2012, 09:20:31 PM
Now, considering that everything can be compiled into a single file. Des encrypted, the password entry makes no sense, right?

The password does make sense:
Quote from: roy_043 on July 11, 2012, 09:15:13 AM
The password does not protect the ODCL file itself. However, if a password protected project has been loaded in the CAD-program the password is required for the (Project_Export) function. This prevents an embedded ODCL project from being accessed by unauthorized users.
Title: Re: Protect the project. Odcl with a password
Post by: roy_043 on July 17, 2012, 01:29:06 AM
Quote from: Emiliano on July 16, 2012, 11:18:22 PM
your example worked with the same ...

I think that you are confused by a search path issue here. The lisp program in my sample first tries to find BC_Compile_Sample_Base64.txt. If this file is compiled into a des/vlx project it will automatically be found, else the CAD program will try to find it in its search path. If the program cannot find that file it tries to load the ODCL file using (dcl_Project_Load) instead. Again the odcl file has to be found in the search path.

My method is to work with the odcl file. I have automated the process of creating a des file. It is a single drag-and-drop action. During that process the base64 text file is created and compiled. The lisp program is set up in such a way that it will work with the base64 text file, if found, or else with the odcl file.

Thinking some more about this, the code for (c:Test) can be improved by adding a (findfile):
Code (autolisp) Select
(defun c:Test ()
  (if
    (not
      (or
        (dcl_Project_Import (vl-get-resource "BC_Compile_Sample_Base64"))
        (and
          (findfile "BC_Compile_Sample.odcl")
          (dcl_Project_Load "BC_Compile_Sample" T)
        )
      )
    )
    (progn
      (princ "\nError: odcl dialog not found ")
      (exit)
    )
  )
  (dcl_Form_Show BC_Compile_Sample_Form1)
)
Title: Re: Protect the project. Odcl with a password
Post by: roy_043 on July 17, 2012, 02:07:21 AM
Quote from: Emiliano on July 16, 2012, 09:20:31 PM
4. I renamed the file "BC_Compile_Sample.lsp" in "BC_Compile_Sample.txt"
A file with the .txt extension cannot be opened in ODCL studio.

Quote from: roy_043 on July 12, 2012, 09:57:38 AM
Please note that you can also put the base64 string (or list-of-strings) in the lisp file itself or in a separate lisp file.
I think that if you want to put the odcl project in a separate lisp file you should also compile it into a separate des file. It doesn't make a lot of sense otherwise. See attached sample.
Title: Re: Protect the project. Odcl with a password
Post by: Emiliano on July 17, 2012, 10:04:44 PM
Hello Roy,
Thanks again for all the details and clarifications.

I like the idea of ​​saving the project odcl format. Lsp.
I like having all files nested within a single file. Des
However, I did some tests with DESCoder, and the only way I found is to save the dialog in txt format and then insert it in the Resource section.

I can confirm that this is correct?
I tried to insert the file. Lsp dialogue in the lisp section, but it did not work ...
Title: Re: Protect the project. Odcl with a password
Post by: roy_043 on July 18, 2012, 02:10:56 AM
Quote from: http://www.lt-extender.com/LT-Extender/englisch/inhalte/DEScoder/DESCoder.htmRemarks :
All source Lisp files will be merged into a single Lisp file, using the displayed order, and then included in target *.des "container" file - as result, the Lisp code from the files is loaded in exactly that sequence. Therefore, that order can effect the Lisp code in its functionality !

If you merge the two lisp files from my sample BC_Compile_Sample_2.zip in this order:
BC_Compile_Sample.lsp (the ODCL project)
BC_Compile_Sample_Functions.lsp

This code from BC_Compile_Sample_Functions.lsp will no longer work:
Code (autolisp) Select
(dcl_Project_Import (load "BC_Compile_Sample"))

However, if you flip the order of the lisp files and save the file to "BC_Compile_Sample.des", the code will theoretically still work if the des file is found in the search path of the CAD-program. But, for obvious reasons, that would be a bad idea.

Your approach works because ODCL is flexible about the format of the text file and does have the advantage of only two files. But you do have to change the extension of the ODCL project file from .lsp to .txt every time you want to compile.

I am still in favour of the base64 text file approach. As mentioned, I have automated the process of creating a des file. All I have to do is drag-and-drop a 'special' lisp file onto a drawing. Something like this will work:
Code (autolisp) Select
; ...
; ...
(load Create_Base64.lsp)
(Create_Base64
  "D:\\LispProjects\\BC_Compile_Sample\\BC_Compile_Sample.odcl"
  "MYPASS"
  "D:\\LispProjects\\BC_Compile_Sample\\BC_Compile_Sample_Base64.txt"
)
(startapp
  (strcat
    "C:\\Program Files\\Bricsys\\Bricscad V" (itoa (atoi (getvar '_vernum))) "\\DESCoder.exe "
    "D:\\LispProjects\\BC_Compile_Sample\\BC_Compile_Sample.prv"
  )
)
(princ)


Create_Base64.lsp (slightly improved version):
Code (autolisp) Select
(princ "\nLoading... ")
(setvar 'cmdecho 0)
(command "OPENDCL")
(setvar 'cmdecho 1)

; project  - ODCL file with full path as string.
; password - Password as string.
; file     - Text file with full path as string.
(defun Create_Base64 (project password file)
  (setq project (dcl_Project_Load project T))
  (setq file (open file "w"))
  (write-line (dcl_Project_Export project password) file)
  (close file)
  (princ)
)