Advertisement
Kolpa

encrypter

May 30th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. table1 = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}
  2. table2 = {}
  3. table3 = {}
  4. output = ""
  5. shell.run("clear")
  6. print("enter the offset")
  7. offset = tonumber(read())
  8. print("enter the text")
  9. input = read()
  10.  
  11.  
  12. if offset < 26 then
  13.  
  14.  
  15. for x=1, #table1+offset do
  16. if x <= #table1 then
  17. table.insert(table2,table1[x+offset])
  18. else
  19. table.insert(table2,table1[x-#table1])
  20. end
  21. end
  22.  
  23.  
  24. for x=1,string.len(input) do
  25. char = string.sub(input,x,x)
  26. table.insert(table3,char)
  27. end
  28.  
  29. for x=1,#table3 do
  30.     for z=1,#table1 do
  31.         if table1[z] == table3[x] then
  32.         output = output..table2[z]
  33.         end
  34.     end
  35. end
  36. print("the encrypted text:")
  37. print(output)
  38. else
  39. print("ERROR offset over 26")
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement