Zimpel (Encoding / Decoding of files)
Posted: Sun Jan 17, 2016 3:32 pm
A small module able to encode and decode files based on the classic LZ78 algorithm.
Instructions
Zimpel can encode and decode strings:
There are also functions for encoding and decoding tables:
Example output for ("Hello World. How are you?"):
I wrote it for fun, but I thought it might be useful for some people. Could be used to encode save games so they can't be edited (easily).
The code lives on github.
Instructions
Zimpel can encode and decode strings:
Code: Select all
local Zimpel = require('Zimpel')
local code = Zimpel.encode( "I have come here to chew bubblegum and kick ass...and I'm all out of bubblegum." )
print( code )
local msg = Zimpel.decode( code );
print( msg )
Code: Select all
local Zimpel = require('Zimpel')
local example = {
bubblegum = false,
kickass = true,
equipment = {
"sunglasses",
"shotgun"
}
}
local code = Zimpel.encodeTable( example )
print( code )
local dtable = Zimpel.decodeTable( code );
for i, v in pairs( dtable ) do
print( i, v )
end
Code: Select all
0H 0e 0l 3o 0 0W 0o 0r 3d 0. 5H 7w 5a 8e 5y 7u 0?
The code lives on github.