be careful! the mime encoder and decoder have a nasty bug in LuaSocket 2.0.2 which causes them to give back bad data when encoding larger than 384 bytes
http://osdir.com/ml/lua@bazar2.conectiva.com.br/2010-03/msg00832.html
use this code instead:
[code]
function base64.encode(data)
local len = data:len()
local t = {}
for i=1,len,384 do
local n = math.min(384, len+1-i)
if n > 0 then
local s = data:sub(i, i+n-1)
local enc, _ = mime.b64(s)
t[#t+1] = enc
end
end
return table.concat(t)
end
function base64.decode(data)
local len = data:len()
local t = {}
for i=1,len,384 do
local n = math.min(384, len+1-i)
if n > 0 then
local s = data:sub(i, i+n-1)
local dec, _ = mime.unb64(s)
t[#t+1] = dec
end
end
return table.concat(t)
end
[/code] [import]uid: 122310 topic_id: 29710 reply_id: 119690[/import]