Skip to content

Instantly share code, notes, and snippets.

@bmwalters
Created October 12, 2015 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmwalters/0e49a04b1537d50845e5 to your computer and use it in GitHub Desktop.
Save bmwalters/0e49a04b1537d50845e5 to your computer and use it in GitHub Desktop.
hash.js leet
cookie.maymays.leetwords = {destroyed = "rekt"}
cookie.maymays.leetpatts = {["(%w+)er"] = "%1or", ["hack(%w+%s)"] = "haxor%1"}
cookie.maymays.leetchars = {a = 4, ["4"] = "a", e = 3, ["3"] = "e", o = "0", ["0"] = "o", l = "1", ["1"] = "l", s = "5", ["5"] = "s", t = "7", ["7"] = "t"}
cookie.maymays.leet = function(inp)
inp = string.lower(inp)
for patt, replacement in pairs(cookie.maymays.leetpatts) do
inp = string.gsub(inp, patt, replacement)
end
for word, replacement in pairs(cookie.maymays.leetwords) do
inp = string.gsub(inp, " "..word.." ", " "..replacement.." ")
end
return (string.gsub(inp, ".", function(c)
return cookie.maymays.leetchars[c] or c
end))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment