Compiling or protecting external files with app

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Compiling or protecting external files with app

Post by shaosean » Mon Jul 04, 2011 6:04 am

don't bother with files, just base64encode the image data and place it in the html and then display the html in a rev browser..
Attachments
html_with_embedded_image.zip
(9.35 KiB) Downloaded 269 times

mebtrek
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Sun May 21, 2006 11:46 pm

Re: Compiling or protecting external files with app

Post by mebtrek » Mon Jul 04, 2011 7:43 am

User guide for encrypt refers to Rev Online which provides the synax: encrypt source using cipher with [password|key] passorkey[and salt saltvalue] [and IV IVvalue] [at bit ]

I've tried this syntax in various ways and cannot get it to work on an external file. I would want to encrypt the external html file and maintain it as encrypted on the disk, decrypting it in memory when ran in revBrowser. Research online finds no code examples for encrypting an external file but only a text string, which I've done successfully. If you can post here the code you indicated that works for you, that would be appreciated.

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Compiling or protecting external files with app

Post by shaosean » Mon Jul 04, 2011 9:18 am

read the file into a variable, encrypt it, write the encrypted out to a file.. read in the encrypted file, decrypt it, display in rev browser.. personally i think embedding the files into a custom property is easier (less files to keep track of)..

mebtrek
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Sun May 21, 2006 11:46 pm

Re: Compiling or protecting external files with app

Post by mebtrek » Mon Jul 04, 2011 9:26 pm

shaosean,

Actually, your thought to simply embed the html code rather than to fuss with files seems to be the most elegant solution, although a decrypt/encrypt method of exyernal files would nevertheless be good to know, e.g., for running more involved html files with associated files such as graphics in a revBrowser. Hopefully, Jacque will be able to provide some code.

I couldn’t get the code you sent () to work but I’ve attached here a file that will unzip to a folder containing a Live Code file “Browser_Embedded & External Html File. Rev” and a subfolder “Called Files” that contains a simple html file for illustrative use. The rev file contains the following two rev Browsers:

1) Browser_Embedded Html Code
This one attempts to open the html file by running its code embedded in the contents of a field, according to your suggested method. The calling button answers the variable and shows that it only results in part of the code and not the actual formatted complete html run.

2) Browser_External Html Code
This one runs successfully the external html file.

As stated, the former embedded option would be most favorable if it could be made to work. Otherwise, I’m back to square 1 attempting to encrypt-decrypt-encrypt external html files.

Please have a look and let me know if I’m missing something in the former code. If you can edit and return it, that would be great!
Attachments
Browser For Forum.zip
(78.2 KiB) Downloaded 261 times

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Compiling or protecting external files with app

Post by shaosean » Tue Jul 05, 2011 6:34 am

It works, just the following code is "wrong" (I say it in quotes because it is technically correct, just not for what we need)

Code: Select all

on abOpenBrowser pURL
  local tWindowId
  put the windowid of this stack into tWindowId
  
  local tBrowserId
  put revBrowserOpen(tWindowId, pURL) into tBrowserId
   
  if tBrowserID contains "error" or tBrowserId is not an integer then
    answer warning tBrowserId
    exit to top
  end if
  set the altBrowserID of this stack to tBrowserId
end abOpenBrowser
This needs to be changed from:

Code: Select all

put revBrowserOpen(tWindowId, pURL) into tBrowserId
to:

Code: Select all

put revBrowserOpen(tWindowId) into tBrowserId
revBrowserSet tBrowserID, "htmlText", pUrl
the reason for this change is your parameter pUrl is not actually a URL but raw HTML, so passing it as the second parameter of revBrowserOpen will fail, so we need to manually set the htmlText of the browser using the revBrowserSet command..

mebtrek
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Sun May 21, 2006 11:46 pm

Re: Compiling or protecting external files with app

Post by mebtrek » Tue Jul 05, 2011 11:30 am

Thank you, shaosean. That little parameter fix does it! Works like a charm. Your assistance and that of others who chimed in is greatly appreciated!

Post Reply