eivast.blogg.se

Base64 encoding wikipedia
Base64 encoding wikipedia










base64 encoding wikipedia base64 encoding wikipedia
  1. BASE64 ENCODING WIKIPEDIA HOW TO
  2. BASE64 ENCODING WIKIPEDIA CODE

BASE64 ENCODING WIKIPEDIA CODE

The following code is not as fast as the mime C-Module - yet on smaller values the loading time can make a program slower, too. I want to apologize if somebody encountered a serious error with the former version of base64 - Not all logical functions can be easily replaced with mathematical ones, so I had to find a way around.

BASE64 ENCODING WIKIPEDIA HOW TO

If (#x ~= 8) then return '' end local c=0įor i=1,8 do c=c+(x:sub(i,i)= '1' and 2^(8-i) or 0) end return string.char(c)Įnd - command line if not called as library if (arg ~= nil) then local func = 'enc' for n,v in ipairs(arg) do if (n > 0) then if (v = "-h") then print "a text/data" break elseif (v = "-e") then func = 'enc' elseif (v = "-d") then func = 'dec' else print( _G(v)) end end end else module( 'base64', eall)īase64 is also implemented in the b64/ unb64 methods in LuaSocket ? ( ), but you may still want to use this snippet for its few requirements - and it is a nice example with educational value for how to perform logical operations without actual bit-shift or OR operators. Lua 5.1+ base64 v3.0 (c) 2009 by Alex Kloss - licensed under the terms of the LGPL2 - character table string local b= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' - encoding function enc(data)įor i=8,1,-1 do r=r.(b%2^i-b%2^(i-1)>0 and '1' or '0') end return r Įnd). Since the last implementation, I had a small competition for the smallest Base64 codec in JavaScript ? - converting the new results to lua gave the following, very small as fast codec: The following implementation provides some samples of Base64 encoder/decoder functions (for background see ). Lua-users wiki: Base Sixty Four Base Sixty Four












Base64 encoding wikipedia