Add the original base64 class I was using as an alternative if mime is not loaded.

This commit is contained in:
Mark Crane
2015-04-06 06:25:42 +00:00
parent 5fe09e3e02
commit 3bac48cebb
2 changed files with 50 additions and 4 deletions

View File

@@ -2,12 +2,22 @@ base64 = {}
-- encode a string and return a base64 string
function base64.encode(s)
local mime = require("mime");
return (mime.b64(s));
if package.loaded["mime"] then
local mime = require("mime");
return (mime.b64(s));
else
dofile(scripts_dir.."/resources/functions/base64_alex.lua");
return base64.enc(s);
end
end
--decode a base64 string and return a string
function base64.decode(s)
local mime = require("mime");
return (mime.unb64(s));
if package.loaded["mime"] then
local mime = require("mime");
return (mime.unb64(s));
else
dofile(scripts_dir.."/resources/functions/base64_alex.lua");
return base64.dec(s);
end
end