Cryptograhy

Richard Gaskin ambassador at fourthworld.com
Tue Aug 5 21:47:23 EDT 2014


JB wrote:
> I was testing base64 and the Pack function
> written by Richard Gaskin and after packing
> and unpacking the data appears the same
> but does not properly write to a file.
>
> For instance I have a image that I read as a binary
> and put the info in a field.  Then I base64Encode it
> and put the date into a field.  I am able to take the
> encoded data and use base64Decode which will
> decode it to its original form and I am able to write
> that data to a file and I have the original image.
>
> When I use the Pack function it does the same thing
> but adds a password if you want it and encrypts it.
>
> After I unPack the date the date looks the same as
> the original but when I write the date to a file I end
> up with a corrupted file and cannot view the image.
>
> Does anyone know why the file gets corrupted?  I
> have the same problem when I use base64Encode
> and convert the encoded ascii data to hex and back
> to ascii then decode it.  The data looks the same but
> I end up with a corrupted file.

fwPack/fwUnpack were written as quick workarounds for simple encryption 
long before LC provided industrial-strength encryption.  While still 
useful in some contexts (I use it often for simple masking), for true 
encryption I use LC's built-in encrypt/decrypt commands.

As for how your files is corrupted it's hard to say without seeing the 
code, but often what happens with seemingly corrupted files is that 
binary data is being written without specifying a binary write form.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list