Tag:group decryption mod base string body ast else byte
Local function encodeBase64 (source_str) Local b64chars = ' abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/' local s64 = ' local str = SOURCE_STR while #st R > 0 do local bytes_num = 0 Local buf = 0 for byte_cnt=1,3 do buf = (BUF * 256) If #str > 0 Then buf = buf + string.byte (str, 1, 1) str = string.sub (str, 2) Bytes_num = bytes_num + 1 end end for Group_cnt=1, (bytes_num+1) do local b64ch AR = Math.fmod (Math.floor (buf/262144), + 1 S64 = s64). String.sub (B64chars, B64char, B64char) buf = buf * "End for Fill_cnt=1" (3-bytes_num) do S64 = S64. ' = ' End end return s64endlocal function decodeBase64 (str64) Local b64chars = ' Abcdefghijklmnopqrstuvwxyzab cdefghijklmnopqrstuvwxyz0123456789+/' local temp={} for i=1,64 do Temp[string.sub (b64chars,i,i)] = i enD temp[' = ']=0 local str= "" For I=1, #str64, 4 does if i> #str64 then break end Loca L data = 0 Local str_count=0 for j=0,3 does local str1=string.sub (STR64,I+J,I+J) if not TEMP[STR1] then return to end If TEMP[STR1] < 1 then data = data * 64 else data = data * + temp[str1]-1 Str_count = str_count + 1 End End for j=16,0,-8 does if str_count > 0 then str=str. String.char (Math.floor (Data/math.pow (2,j))) Data=math.mod (Data,math.pow (2,j)) Str_count = St R_count-1 end end Local last = Tonumber (String.byte (str, String.len (str), String.len (str))) If last = = 0 Then str = string.sub (str, 1, String.len (str)-1) End return Strend
Lua's base64 encryption and decryption algorithm.