View difference between Paste ID: 0d4Fmkju and hw7fvELe
SHOW: | | - or go back to the newest paste.
1-
-- Vigenère cipher encryption
1+
function v(k,m)local e={}local l=#k for i=1,#m do local a=k:byte((i-1)%l+1)local b=m:byte(i)e[i]=string.char(bit32.bxor(b,a))end return table.concat(e)end local B='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' function b64e(d)local e={}local l=#d local i=1 while i<=l do local a=d:byte(i)or 0 local b=d:byte(i+1)or 0 local c=d:byte(i+2)or 0 local n=(a*65536)+(b*256)+c e[#e+1]=B:sub(math.floor(n/262144)+1,math.floor(n/262144)+1)e[#e+1]=B:sub(math.floor(n/4096)%64+1,math.floor(n/4096)%64+1)e[#e+1]=B:sub(math.floor(n/64)%64+1,math.floor(n/64)%64+1)e[#e+1]=B:sub(n%64+1,n%64+1)i=i+3 end local p=l%3 if p==1 then e[#e-1]='='e[#e]='='elseif p==2 then e[#e]='=' end return table.concat(e)end function b64d(e)local d={}local i=1 local l=#e local function c2v(c)local idx=B:find(c)return idx and(idx-1)or 0 end while i<=l do local a=c2v(e:sub(i,i))local b=c2v(e:sub(i+1,i+1))local c=c2v(e:sub(i+2,i+2))local e=c2v(e:sub(i+3,i+3))local n=(a*262144)+(b*4096)+(c*64)+e d[#d+1]=string.char(math.floor(n/65536)%256)if b~=64 then d[#d+1]=string.char(math.floor(n/256)%256)end if c~=64 then d[#d+1]=string.char(n%256)end i=i+4 end return table.concat(d)end local k="HTIWaoithwaioPTHio"local m="Hello World"local b64=b64e(m)print("Base64 Encoded:",b64)local e=v(k,b64)print("Vigenère Encrypted:",e)print("Base64 Decoded:",b64d(v(k,e)))
2-
function v(k, m)
2+