Cryptograhy

JB sundown at pacifier.com
Tue Aug 5 22:03:53 EDT 2014


Thanks for the quick response and info.

I am using this code to write the file

    open file filePath for binary write
    put fld id 1004 into theData
    write theData to file filePath

and it writes the data properly if all
I do is base64encode/decode.  When
the encoded data is altered and then
put back to what appears to be the
same and decoded it ends up corrupted
after decoding it.

I can take a Hex file and convert it to
ascii or binary and back again and it
will write the image properly.  But when
I convert the ascii from base64encode
it ends up corrupted.  I have used regex
to remove NULLS and CRLF but that does
not solve the problem.

I can send you the code but the code that I
am testing at the moment is fwPack.  Are
you able to use the code to pack and unpack
a image and write it to disk?

thanks again,
-=>JB<=-


On Aug 5, 2014, at 6:47 PM, Richard Gaskin <ambassador at fourthworld.com> wrote:

> 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
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 




More information about the use-livecode mailing list