News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
MurgaLua Compiler
Author Message
Juergen
Member
***


Posts: 81
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #1
RE: MurgaLua Compiler

JohnMurga Wrote:
Embed it ... By using the new picture and hex functions to dump as a hex string, and then reload/decode it as hex string at runtime.


Ouch, I was asking myself, why you introduced those two functions. The functionality (base64 en/decoding) is already available in murgaLua and is actually superior.

Code:
if arg[1]==nil then print("You should provide a filename!") return 1 end
binary_name=io.open(arg[1],"rb")
if not binary_name then print("You should provide a valid filename!") return 1 end
print("Load and summing binary data")
binary_data=binary_name:read("*a")
binary_name:close()
binary_size=#binary_data
binary_md5sum=md5.sum(binary_data)
print("encoding, decoding and summing b64 data")
b64_string=(mime.b64(binary_data,nil))
b64_string_size=#b64_string
binary_data_b64=(mime.unb64(b64_string,nil))
binary_b64_md5sum=md5.sum(binary_data_b64)
binary_data_b64=nil
b64_string=nil
collectgarbage()
print("encoding, decoding and summing hex data")
hex_string=murgaLua.encodeDataAsHex(binary_data)
hex_string_size=#hex_string
binary_data_hex=murgaLua.decodeDataFromHex(hex_string)
binary_hex_md5sum=md5.sum(binary_data_hex)
hex_string=nil
binary_data_hex=nil
binary_data=nil
collectgarbage()
if binary_md5sum~=binary_b64_md5sum then print("Something is wrong with the b64 function!") return 1 end
if binary_md5sum~=binary_hex_md5sum then print("Something is wrong with the hex function!") return 1 end
print("The original file size was "..binary_size.." bytes long")
print(string.format("The b64 encoded data is %d bytes long, which is %.2f%% more than the original data",b64_string_size,b64_string_size/binary_size*100-100))
print(string.format("The hex encoded data is %d bytes long, which is %.2f%% more than the original data",hex_string_size,hex_string_size/binary_size*100-100))
print(string.format("The hex encoded string is %.2f%% bigger than the b64 encoded one",hex_string_size/b64_string_size*100-100))


If you test it with a big file you can see that the hex functions are also much slower.

I think it would be a good idea to either remove the two functions or to call mime de/encoding internally.

Juergen

02-01-2008 09:08 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
MurgaLua Compiler - iGame3D - 01-31-2008, 09:54 PM
RE: MurgaLua Compiler - mikshaw - 02-01-2008, 12:00 AM
RE: MurgaLua Compiler - JohnMurga - 02-01-2008, 02:45 AM
RE: MurgaLua Compiler - JohnMurga - 02-01-2008, 02:50 AM
RE: MurgaLua Compiler - iGame3D - 02-01-2008, 08:05 AM
RE: MurgaLua Compiler - Juergen - 02-01-2008 09:08 AM
RE: MurgaLua Compiler - JohnMurga - 02-01-2008, 09:38 AM
RE: MurgaLua Compiler - iGame3D - 02-01-2008, 03:26 PM
RE: MurgaLua Compiler - Juergen - 02-01-2008, 09:08 PM
RE: MurgaLua Compiler - JohnMurga - 02-01-2008, 11:47 PM
RE: MurgaLua Compiler - Juergen - 02-06-2008, 04:33 AM
RE: MurgaLua Compiler - JohnMurga - 02-06-2008, 08:21 AM
MurgaLua Compiler Platforms - iGame3D - 02-06-2008, 09:24 AM
RE: MurgaLua Compiler - Juergen - 02-06-2008, 09:29 AM
RE: MurgaLua Compiler - Juergen - 02-06-2008, 08:14 PM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: