cross-platform compress & decompress

Mark Brownell gizmotron at
Tue Dec 2 09:48:17 CST 2003

On Tuesday, December 2, 2003, at 04:48  AM, Wouter wrote:

> The < put binaryDecode("N",str,halfBlock) into numConverted >
> in your blowfish handler can produce an unsigned integer on
> the Windows platform where as on the Mac a signed integer is
>  produced. This is probably an engine related problem.
> To test this try the following on both platforms and compare
> [snip]
> Greetings,
> WA
> PS In fact with a litle adjustment your Blowfish stack is working on 
> both platforms

I tried it with a speed test and the solution I'm using now:

on mouseUp
   ## I added speed testing
   put num2char("169,170,171,172") into x
   ## N - decode signed four-byte integers in network order
   put binaryDecode("N",x,halfBlock1) into numConverted
   ## I - decode unsigned four-byte integers in host order
   put the milliseconds into zap1
   repeat with i = 1 to 100000
     put binaryDecode("I",x,halfBlock2) into numConverted
   end repeat
   put the milliseconds into zap2
   put zap2 - zap1 into t1
   ## my solution I'm using now
   put the milliseconds into zap6
   repeat with ii = 1 to 100000
     put charToNum(char 4 of x) + (charToNum(char 3 of x) * 256) + 
(charToNum(char 2 of x) * 65536) + (charToNum(char 1 of x) * 16777216) 
bitAnd 4294967295 into halfBlock3
   end repeat
   put the milliseconds into zap7
   put zap7 - zap6 into t2
   put halfblock1 && halfblock2 && halfblock3 && t1 && t2
   ## result = -1448432724 2846534572 2846534572 294 664
end mouseUp

function num2char sx
   repeat for each item i in sx
     put numtochar(i)  after z
   end repeat
   return z
end num2char

I'll have to see if this works with macToIso/isoToMac for delivery. I'm 
curently using ascii numbers that in the end take the charSet issue out 
of the delivery issue for decryption. The numbers also split out into 
an array that allows for one step to be dropped during decryption.

Thank you for mentioning this. This could add at the least a 100% 
increase in speed to the current state of the working version.

Mark Brownell

More information about the use-livecode mailing list