Skip to content

Instantly share code, notes, and snippets.

@ExtReMLapin
Last active February 15, 2016 14:12
Show Gist options
  • Save ExtReMLapin/dc9cdee88b74e8d069a6 to your computer and use it in GitHub Desktop.
Save ExtReMLapin/dc9cdee88b74e8d069a6 to your computer and use it in GitHub Desktop.
rot finder DGSE entry chalenge kek 2ez4me
local str = "RH UNTR ONTUDY CDBGHEEQDQ BDBH, ZK JHMCH DRS EZHS ONTQ UNTR !"
local function ascii_base(s)
return s:lower() == s and ('a'):byte() or ('A'):byte()
end
local function caesar_cipher(str, key)
return (str:gsub('%a', function(s)
local base = ascii_base(s)
return string.char(((s:byte() - base + key) % 26) + base)
end))
end
local function rot13_cipher(i)
return caesar_cipher(str, i)
end
local function rot13_decipher(i)
return caesar_cipher(str, i)
end
local function rot(i)
print(i, rot13_cipher(i))
print(-i, rot13_decipher(-i))
end
local i = 1;
while i < 13 do
rot(i)
i = i+1
end
@Applx
Copy link

Applx commented Jan 12, 2016

lua -e "io.stdout:setvbuf 'no'" "DGSErot.lua"
lua: DGSErot.lua:10: attempt to perform arithmetic on global 'key' (a nil value)
stack traceback:
DGSErot.lua:10: in function DGSErot.lua:8
[C]: in function 'gsub'
DGSErot.lua:8: in function DGSErot.lua:7
(tail call): ?
DGSErot.lua:21: in function 'rot'
DGSErot.lua:27: in main chunk
[C]: ?

can you help me?

@ExtReMLapin
Copy link
Author

Fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment