Advertisement
Vaeb

My Encrypter 2

Jul 15th, 2016
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. local MinASCII = 65
  2. local MaxASCII = 90
  3.  
  4. local EncMsg = [==============================[
  5. print("Hello, world!")
  6. ]==============================]
  7.  
  8. local random = math.random
  9. local toByte = string.byte
  10. local toChar = string.char
  11.  
  12. local function encryptString(Msg)
  13.     local NewKeyNums = {}
  14.     local NewEncryptionChars = {}
  15.  
  16.     local NewEncryption = ""
  17.  
  18.     local MaxAsc = MinASCII+25
  19.     for i = 1, #Msg do
  20.         NewKeyNums[#NewKeyNums+1] = random(MinASCII, MaxAsc)
  21.     end
  22.  
  23.     for i = 1, #Msg do
  24.         local OrigByte = toByte(Msg:sub(i, i))
  25.         local EncryptedChar = toChar(offsetASCII(OrigByte, NewKeyNums[i]))
  26.         local TotalOffset = (toByte(EncryptedChar) - OrigByte) * -1
  27.         NewKeyNums[i] = TotalOffset
  28.         NewEncryptionChars[#NewEncryptionChars+1] = EncryptedChar
  29.     end
  30.  
  31.     local NewKey = table.concat(NewKeyNums, "%20")
  32.     local NewEncryption = table.concat(NewEncryptionChars)
  33.     return NewKey, NewEncryption
  34. end
  35.  
  36. math.randomseed(tick())
  37.  
  38. local NewKey, NewEncryption = encryptString(EncMsg)
  39.  
  40. print("Key: " .. NewKey) --The key
  41. print("Encryption: " .. NewEncryption) --The encryption
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement