Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local MinASCII = 65
- local MaxASCII = 90
- local EncMsg = [==============================[
- print("Hello, world!")
- ]==============================]
- local random = math.random
- local toByte = string.byte
- local toChar = string.char
- local function encryptString(Msg)
- local NewKeyNums = {}
- local NewEncryptionChars = {}
- local NewEncryption = ""
- local MaxAsc = MinASCII+25
- for i = 1, #Msg do
- NewKeyNums[#NewKeyNums+1] = random(MinASCII, MaxAsc)
- end
- for i = 1, #Msg do
- local OrigByte = toByte(Msg:sub(i, i))
- local EncryptedChar = toChar(offsetASCII(OrigByte, NewKeyNums[i]))
- local TotalOffset = (toByte(EncryptedChar) - OrigByte) * -1
- NewKeyNums[i] = TotalOffset
- NewEncryptionChars[#NewEncryptionChars+1] = EncryptedChar
- end
- local NewKey = table.concat(NewKeyNums, "%20")
- local NewEncryption = table.concat(NewEncryptionChars)
- return NewKey, NewEncryption
- end
- math.randomseed(tick())
- local NewKey, NewEncryption = encryptString(EncMsg)
- print("Key: " .. NewKey) --The key
- print("Encryption: " .. NewEncryption) --The encryption
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement