Protect the project. Odcl with a password

Started by Emiliano, July 11, 2012, 02:10:25 AM

Previous topic - Next topic

roy_043

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.

Emiliano

#16
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

Emiliano

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!

roy_043

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.

roy_043

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

roy_043

#20
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.

Emiliano

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

roy_043

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