Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function encrypt(msg,key)
- local num = ""
- for i = 1, #key do
- local let = key:sub(i,i):byte()
- num = let <= 9 and num.."99"..let or let<=99 and num.."9"..let or num..let
- num = #msg..num
- end
- math.randomseed(tonumber(num))
- local encrypt = ""
- for i = 1, #msg do
- local rotation = math.random(0,94)
- local byte = msg:sub(i,i):byte()
- local rotate = rotation+byte <= 127 and rotation +byte or ((rotation+byte)%127)+32
- encrypt = encrypt..string.char(rotate)
- end
- return encrypt
- end
- function decrypt(msg,key)
- local num = ""
- for i = 1, #key do
- local let = key:sub(i,i):byte()
- num = let <= 9 and num.."99"..let or let<=99 and num.."9"..let or num..let
- num = #msg..num
- end
- math.randomseed(tonumber(num))
- local decrypt = ""
- for i = 1, #msg do
- local rotation = math.random(0,94)
- local byte = msg:sub(i,i):byte()
- local rotate = byte-rotation >= 32 and byte-rotation or byte-rotation
- if rotate < 32 then
- rotate = rotate+95
- end
- decrypt = decrypt..string.char(rotate)
- end
- return decrypt
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement