Encrypting a file

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
friday
Posts: 158
Joined: Mon May 09, 2011 3:01 pm

Encrypting a file

Post by friday » Wed Aug 31, 2011 11:02 am

Hi

I'd like to be able to encrypt some files from a Windows PC onto a USB stick. Could I do this with a LiveCode stack? The files are mostly large (up to 1 GB) Microsoft Access database files. I've looked at the encrypt/decrypt facilities in the LiveCode dictionary but I get the impression that's used for encrypting strings or records, not entire files. I've searched the Lessons for encryption but found nothing.

I'd also like to zip as well as encrypt the files like in WinZip (I can't install WinZip on the Windows PC, which is why I wondered if LiveCode might be an answer.)

Thanks in anticipation
Geoff
Using LiveCode 9.0.1 for Mac/PC/iOS
MacBook Pro 2019 16GB
macOS Monterey v12.4
2.6 GHz 6-Core Intel Core i7

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Encrypting a file

Post by BvG » Wed Aug 31, 2011 2:14 pm

All windows versions since xp can create zip files (right click, send to..., zip compressed folder). The ability is also available via command line, but does not include the encrypted zip format. See also Wikipedia.

In LC both zip and encryption are supplied as externals, and overtly complex. The encrypted zip format is also not supported. However, it is possible to encrypt anything in a container, and files are part of the definition of "containers" as used in the dictionary. On the other hand, all data would need to be loaded into RAM, putting a practical upper bound on the size of the encrypted data.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

friday
Posts: 158
Joined: Mon May 09, 2011 3:01 pm

Re: Encrypting a file

Post by friday » Wed Aug 31, 2011 7:26 pm

I see. Thanks for that, BvG, very helpful. It would appear that what I'm thinking of wouldn't be practical, loading the entire file into memory. Unless... I see there is a read from file function which would allow me to read in the database file in chunks of say, 1K bytes, encrypt it, and then write it out to a new file. No, it can't be that easy... I'm probably looking at this too simplistically, as I've not done this before!

Thanks
Geoff
Using LiveCode 9.0.1 for Mac/PC/iOS
MacBook Pro 2019 16GB
macOS Monterey v12.4
2.6 GHz 6-Core Intel Core i7

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Encrypting a file

Post by Mark » Wed Aug 31, 2011 8:21 pm

Hi Geoff,

Please, keep in mind that zip files may be protected by a password, but are NOT encrypted!

You can encrypt big files by reading them piece by piece, say 10MB at a time, and appending the encrypted data to a file, using unique strings to identify the parts. Unfortunately, this might be very slow.

If you have very big files and your data is really sensitive, perhaps you should think of an encrypted external drive?

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

friday
Posts: 158
Joined: Mon May 09, 2011 3:01 pm

Re: Encrypting a file

Post by friday » Thu Sep 01, 2011 8:10 am

Hi

Thanks Mark. Yes, it looks like an encrypted USB stick would be easier. I was hoping to use my new LiveCode skills but never mind...!

Thanks
Geoff
Using LiveCode 9.0.1 for Mac/PC/iOS
MacBook Pro 2019 16GB
macOS Monterey v12.4
2.6 GHz 6-Core Intel Core i7

Post Reply