Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --cle = "chiffrement"
- --a = "BaseOs est 100% secure!"
- --at = {a:byte(1,#a)}
- --clet = {cle:byte(1,#cle)}
- function chiffre(cle,text)
- local retour = ""
- local retourT = {}
- local textT = {text:byte(1,#text)}
- local cleT = {cle:byte(1,#cle)}
- local ic = 1
- for i=1,#textT do
- if ic > #cleT-1 then
- ic = 1
- else
- ic = ic+1
- end
- retourT[i] = textT[i] + cleT[ic]
- --print(textT[i].."+"..cleT[ic].."="..retourT[i])
- if retourT[i] > 255 then
- retourT[i] = retourT[i] - 255
- end
- --print(i.." "..ic)
- retour = retour..string.char(retourT[i])
- end
- return retour
- end
- function dechiffre(cle,text)
- local retour = ""
- local retourT = {}
- local textT = {text:byte(1,#text)}
- local cleT = {cle:byte(1,#cle)}
- local ic = 1
- for i=1,#textT do
- if ic > #cleT-1 then
- ic = 1
- else
- ic = ic+1
- end
- retourT[i] = textT[i] - cleT[ic]
- --print(textT[i].."+"..cleT[ic].."="..retourT[i])
- if retourT[i] < 0 then
- retourT[i] = retourT[i] + 255
- end
- --print(i.." "..ic)
- retour = retour..string.char(retourT[i])
- end
- return retour
- end
Add Comment
Please, Sign In to add comment