Advertisement
incinirate

Cryptum

Sep 30th, 2014
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.68 KB | None | 0 0
  1. local tArgs = {...}
  2. local pstr = 10
  3. -- 1=File 2=Out 3=Mode(d/e)
  4. write("Password to "..(tArgs[3]=="d" and "open" or "save").." with: ")
  5. local pass = read("*")
  6. local bseed = ""
  7. for i=1,#pass do
  8.   bseed = bseed..string.byte(pass:sub(i,i))
  9. end
  10. local ttef = fs.open(tArgs[1],"r")
  11. local tte = ttef.readAll()
  12. ttef.close()
  13. local endt = ""
  14. for i=1,#tte do
  15.   math.randomseed(bseed+i)
  16.   local shift = math.random(1,pstr)
  17.   endt = endt..string.char(string.byte(tte:sub(i,i))+(tArgs[3]=="d" and shift or -1*shift))
  18.   write(endt:sub(i,i))
  19. end
  20. local efile = fs.open(tArgs[2],"w")
  21. efile.write(endt)
  22. efile.close()
  23. print("\n"..(tArgs[3]=="d" and "Decryption" or "Encryption").." Complete!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement