Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --done in luau
- local msg = 'wow potato'
- function GenerateRandomKey(len)local res=''for _=1,len do res..=tostring(math.random(1,10)-1)end return res end
- function FACT_OffsetLetter(mult)
- return function(msg,key)
- local res=''
- for i=1,#msg do
- local let = msg:sub(i,i)
- local offset = key:sub(i,i)
- local NewByte =
- (let:byte() - 32 + offset * mult) % 223
- local newlet = string.char(NewByte + 32)
- res ..= newlet
- end
- return res
- end
- end
- local Encrypt = FACT_OffsetLetter(1)
- local Decrypt = FACT_OffsetLetter(-1)
- local key = GenerateRandomKey(#msg)
- print(msg,key)
- local m2 = Encrypt(msg,key)
- print(m2)
- local m3 = Decrypt(m2,key)
- print(m3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement