Page 1 of 1

Encryption of a script-only stack in a standalone

Posted: Thu Dec 14, 2017 11:18 am
by yuzutake
I'm trying to use a script-only stack for development, but encrypted when in a standalone.
I'm using this script (some lines are useless):

Code: Select all

on preopenstack
   if the environment is "development" then
      start using stack "mytest.livecodescript"
   else
      start using stack "mytest.livecode"
   end if
   set the destroyStack of stack "mytest" to true
end preopenstack

on savingstandalone
   local theFilename, pwd
   if the scriptOnly of stack "mytest" then
      stop using stack "mytest.livecodescript"
      set the scriptOnly of stack "mytest" to false
      put uuid() into pwd
      set the password of stack "mytest" to pwd
      put the filename of stack "mytest" into theFilename
      set the itemDelimiter to "."
      put "livecode" into the last item of theFilename
      set the filename of stack "mytest" to theFilename
      delete file theFilename
      save stack "mytest"
      close stack "mytest"
      start using stack "mytest.livecode"
      set the passkey of stack "mytest" to pwd
      delete file theFilename
   end if
end savingstandalone

on standaloneSaved pFolder
   set the password of stack "mytest" to empty
end standaloneSaved
The problem is that I get the warning "Could not auto-detect inclusions or security categories because stack is password protected". It's because after savingstandalone, stack "mytest" has a password.
If I remove it at the end of savingstandalone, mytest.livecode isn't encrypted.
Any idea how to fix it?

Re: Encryption of a script-only stack in a standalone

Posted: Thu Dec 14, 2017 4:43 pm
by jacque
I'm not sure why you'd want to use a script only stack for development if it isn't going to be in the distribution. At any rate, the options are:

1. Use a normal stack and set the password in standalone settings.

2. Use manual inclusions so the build doesn't have to search.

Re: Encryption of a script-only stack in a standalone

Posted: Fri Dec 15, 2017 3:19 pm
by yuzutake
I want a script-only stack for development because it's a text file, I use Git.
We can't encrypt a script-only stack from the standalone settings so I'm finding a way to convert it to a normal stack that I can encrypt. But I'd also like to have inclusions auto-detected.

If I add

Code: Select all

set the password of stack "mytest" to empty
at the end of savingstandalone, I indeed have mytest.livecode in the generated folder without a warning, but it is readable with Notepad.

Re: Encryption of a script-only stack in a standalone

Posted: Fri Dec 15, 2017 3:44 pm
by Mikey
Levure does this, FYI. I'm not sure how, though.

Re: Encryption of a script-only stack in a standalone

Posted: Sat Dec 16, 2017 9:44 pm
by jacque
At a guess, you could:

Save the temporary script-only stack as a "real" LiveCode stack on disk. (A kind of "holder" stack is created when LC loads the script-only text file into RAM, so it's already there. Just do a "save-as" on it.)
Set a password on the new stack.
Add that stack to the list in cRevStandaloneSettings["files"].
Do the build.
Delete the script stack you just created.

Make sure your app puts the stack in use.

Re: Encryption of a script-only stack in a standalone

Posted: Mon Dec 18, 2017 8:53 am
by yuzutake
Thanks
I've solved my problem by making the script-only stack a substack:

Code: Select all

on preOpenStack
   if the environment is "development" then
      start using stack "mytest.livecodescript"
   else
      start using stack "mytest"
   end if
end preOpenStack

on savingStandalone
   if the scriptOnly of stack "mytest" then
      set the mainstack of stack "mytest" to me
   end if
end savingStandalone

on standaloneSaved
   start using stack "mytest.livecodescript"
end standaloneSaved
There's only the .exe in the folder, but it's fine.

Re: Encryption of a script-only stack in a standalone

Posted: Mon Dec 18, 2017 3:58 pm
by jacque
You'll probably want to set a password on the substack. It won't inherit the one from the mainstack.