SHARE
TWEET

Untitled

a guest Dec 11th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. input = "According to all known laws of aviation; there is no way a bee should be able to fly. Its wings are too small to get its fat little body off the ground. The bee: of course, flies anyway because bees don't care what humans think is impossible."
  3.  
  4. math.randomseed(os.time())
  5. key = {
  6.   a = "%",
  7.   b = "2",
  8.   c = "+",
  9.   d = "]",
  10.   e = "@",
  11.   f = "9",
  12.   g = "~",
  13.   h = "^",
  14.   i = "`",
  15.   j = ";",
  16.   k = "*",
  17.   l = "#",
  18.   m = ")",
  19.   n = "[",
  20.   o = ":",
  21.   p = "&",
  22.   q = "i",
  23.   r = "(",
  24.   s = "/",
  25.   t = "}",
  26.   u = "7",
  27.   v = "{",
  28.   w = "1",
  29.   x = "=",
  30.   y = "_",
  31.   z = "4",
  32.  
  33.   noise = "-",
  34.   upper = "p",
  35. }
  36.  
  37. key[" "] = "8"
  38. key["."] = "5"
  39. key[","] = "3"
  40. key[":"] = "o"
  41. key[";"] = "w"
  42. key["'"] = "\""
  43. key["!"] = "0"
  44. key["?"] = "!"
  45.  
  46. function code(str)
  47.   local r = ""
  48.   for i = 1, #str do
  49.     replaced = false
  50.     char = string.sub(str, i, i)
  51.  
  52.     if math.random(1,5) == 1 then
  53.      r = (r .. key.noise)
  54.     end
  55.     for _, v in pairs(key) do
  56.       if string.lower(char) ~= char and string.lower(char) == _ then
  57.         r = (r .. key.upper .. v)
  58.         replaced = true
  59.       elseif
  60.         string.lower(char) == _ then
  61.         r = (r .. v)
  62.         replaced = true
  63.       end
  64.       if char == key.noise then
  65.         replaced = true
  66.       end
  67.     end
  68.     if (not replaced) then
  69.       print("Invalid character: " .. char)
  70.     end
  71.   end
  72.  
  73.   return r
  74. end
  75.  
  76. function decode(str)
  77.   local r = ""
  78.   for i = 1, string.len(str) do
  79.     char = string.sub(str, i, i)
  80.  
  81.     if char ~= key.noise then
  82.       for _, v in pairs(key) do
  83.         if char == v then
  84.           if v == key.upper then
  85.             upper = true
  86.           else
  87.             if upper then
  88.               r = r .. string.upper(_)
  89.             else
  90.               r = r .. _
  91.             end
  92.             upper = false
  93.           end
  94.         end
  95.       end
  96.     end
  97.   end
  98.  
  99.   return r
  100. end
  101.  
  102. a = code(input)
  103. print("Coded: " .. a)
  104. io.write("\n")
  105. a = decode(a)
  106. print("Decoded: " .. a)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top