Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 07/02/2016
- --Last update: 27/11/2016
- --[[ Notes:
- Does:
- Gera os próximos unicodes de str para rotation bytes a frente
- Args:
- str --> String
- rotation --> Número para rotacionar a string
- lettersOnly --> Caso true, unicodes além de letras serão ignorados na rotação
- ]]--
- string.rotate = function(str,rotation,lettersOnly)
- if lettersOnly then
- local b,c
- local newStr = {}
- for i = 1,#str do
- b = str:sub(i,i):byte()
- c = (b > 96 and b < 123) and 97 or (b > 64 and b < 91) and 65 or false
- if c then
- newStr[#newStr + 1] = string.char((c + (((b - c) + rotation) % 26)))
- end
- end
- return table.concat(newStr)
- else
- str = str:gsub("(.)",function(c)
- return string.char(c:byte() + rotation)
- end)
- return str
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement