Encryption of a script-only stack in a standalone

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
yuzutake
Posts: 10
Joined: Mon Feb 27, 2017 5:36 pm

Encryption of a script-only stack in a standalone

Post by yuzutake » Thu Dec 14, 2017 11:18 am

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?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4624
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

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

Post by jacque » Thu Dec 14, 2017 4:43 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

yuzutake
Posts: 10
Joined: Mon Feb 27, 2017 5:36 pm

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

Post by yuzutake » Fri Dec 15, 2017 3:19 pm

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.

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 631
Joined: Fri Jun 27, 2008 9:00 pm

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

Post by Mikey » Fri Dec 15, 2017 3:44 pm

Levure does this, FYI. I'm not sure how, though.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4624
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

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

Post by jacque » Sat Dec 16, 2017 9:44 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

yuzutake
Posts: 10
Joined: Mon Feb 27, 2017 5:36 pm

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

Post by yuzutake » Mon Dec 18, 2017 8:53 am

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.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4624
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

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

Post by jacque » Mon Dec 18, 2017 3:58 pm

You'll probably want to set a password on the substack. It won't inherit the one from the mainstack.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Talking LiveCode”