xXm0dzXx

Untitled

Oct 13th, 2012
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. local function convert(chars,dist,inv)
  2. local charInt = string.byte(chars);
  3. for i=1,dist do
  4. if(inv)then charInt = charInt - 1; else charInt = charInt + 1; end
  5. if(charInt<32)then
  6. if(inv)then charInt = 126; else charInt = 126; end
  7. elseif(charInt>126)then
  8. if(inv)then charInt = 32; else charInt = 32; end
  9. end
  10. end
  11. return string.char(charInt);
  12. end
  13.  
  14. local function crypt(str,k,inv)
  15. local enc= "";
  16. for i=1,#str do
  17. if(#str-k[5] >= i or not inv)then
  18. for inc=0,3 do
  19. if(i%4 == inc)then
  20. enc = enc .. convert(string.sub(str,i,i),k[inc+1],inv);
  21. break;
  22. end
  23. end
  24. end
  25. end
  26. if(not inv)then
  27. for i=1,k[5] do
  28. enc = enc .. string.char(math.random(32,126));
  29. end
  30. end
  31. return enc;
  32. end
Advertisement
Add Comment
Please, Sign In to add comment