One Use Only Files

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

One Use Only Files

Post by bidgeeman » Wed Aug 16, 2017 10:39 am

Hi again.
Thought I should start a new thread on this as the other image thread was getting quite large.
Can anyone suggest a way to limit a file, (Image), to 1 time only use in a stack? Even if they
user has made a copy of it?

Bidge

Klaus
Posts: 11012
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: One Use Only Files

Post by Klaus » Wed Aug 16, 2017 10:41 am

Please define "1 time only use"! :D

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: One Use Only Files

Post by bidgeeman » Wed Aug 16, 2017 10:44 am

1 time only use = they load it into the stack and use it as much as they like until they load in another image then the old one would be replaced and deleted. But if they had made a copy of the old file they could easily reload it again and again and again, share it etc. I'm probably asking the impossible once again.

Bidge

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: One Use Only Files

Post by bidgeeman » Wed Aug 16, 2017 11:11 am

Just throwing ideas around. What I time stamped and made a duplicate of the file when it was first loaded ,and only allowed that time stamped copy to be used till another file was loaded? Can anyone find fault in that method? Hoe would I keep track in the software not to load that file ever again though? If it worked off an internal list that list would get huge over time.

Bidge

Klaus
Posts: 11012
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: One Use Only Files

Post by Klaus » Wed Aug 16, 2017 11:30 am

Hi David,

mod date etc. can be modified.
I think you will show a file dialog to the user so he can select an image file right?

In that case I would only save and compare the MD5DIGEST of the files!
Hint: md5digest() returns BINARY data, need I say more? :D

A quick test worked fine:

Code: Select all

on mouseUp pMouseButton
   answer file "select img 1"
   put md5digest(url("binfile:" & IT)) into md1  
   answer file "select img 2"
   put md5digest(url("binfile:" & IT)) into md2
   answer md1 = md2
end mouseUp
Works of course with ALL kind of files.
Hope that gets you started!


Best

Klaus

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: One Use Only Files

Post by bidgeeman » Wed Aug 16, 2017 12:10 pm

Hi Klaus.
Thanks :) I will experiment with this and see how it goes.
Bidge

Klaus
Posts: 11012
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: One Use Only Files

Post by Klaus » Wed Aug 16, 2017 12:16 pm

Hm, another test showed that a copy of a file has the same md5digest as the original file, so that was a quick but not so good idea, I'm afraid... :oops:

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: One Use Only Files

Post by bidgeeman » Wed Aug 16, 2017 12:36 pm

Oh dear.
Back to the drawing board :(
Bidge

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6036
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: One Use Only Files

Post by dunbarx » Wed Aug 16, 2017 3:55 pm

Hi.

Might it be possible to store the imageData of each newly uploaded image, perhaps in a custom property of the stack, and then if any new image's imageData matched an instance in storage, simply destroy the computer.

Craig Newman

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2035
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: One Use Only Files

Post by [-hh] » Wed Aug 16, 2017 8:44 pm

Another option could be:

1. For displaying the proper image hide it and copy it to a temporary image . Then set byte 1 to 5 of the alphaData of the image to "BIDGE". By that, if the image is copied, it is copied with that alphaData. (This will be also copied by LC to byte 1 of the first 5 pixels = bytes 1,5,9,13,17 of the imageData, that's why you always have to set the alphaData before the imageData).

2. Now, if you have loaded a new image then check byte 1 to 5 of the alphaData (or bytes 1,5,9,13,17 of the imageData) before the display.
If it is "BIDGE" then don't display the image, else assume it is proper and do 1.

You could also use e.g. the last pixels and another word. Nobody knows.
shiftLock happens

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: One Use Only Files

Post by bidgeeman » Wed Aug 16, 2017 11:48 pm

Hi dunbarx and [-hh]
They sound like good options. I will experiment with both and let you know how it goes.

Thanks again
Bidge

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6036
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: One Use Only Files

Post by dunbarx » Thu Aug 17, 2017 12:54 am

Thinking about storing the imageData for all these imported pictures, surely, to keep the thing from getting too large, might you store only the first 1K?

Craig

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: One Use Only Files

Post by bidgeeman » Thu Aug 17, 2017 1:15 am

Hi dunbarx,
yes...It's really only a deterrent to the average person. One other question. Is it possible to run a Livecode stack from a server? Maybe a html 5 version of a stack? That way you could theoretically insert a code in each image before it was downloaded.

Bidge

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: One Use Only Files

Post by bidgeeman » Thu Aug 17, 2017 3:07 am

Just thinking....would it be simpler to protect the images if they were hosted on a website and just downloaded into the background area of the poster when required? That way there are no files exchanged physically? Any thoughts or pitfalls on this?

Bidge

Klaus
Posts: 11012
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: One Use Only Files

Post by Klaus » Thu Aug 17, 2017 5:47 pm

Hm, in your second posting you said the user will load an image into the stack and
now you want to load the images from the server, which is exactly the contrary!?

Maybe you should tell us a bit more about your app, I still don't have the slightest idea. :D

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”