Last active
February 15, 2016 14:12
-
-
Save ExtReMLapin/dc9cdee88b74e8d069a6 to your computer and use it in GitHub Desktop.
rot finder DGSE entry chalenge kek 2ez4me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed it