SpaceRanger4321

Sha Login

Dec 31st, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.47 KB | None | 0 0
  1. os.loadAPI("sha")
  2. write("username :: ")
  3. local u = read()
  4. write("password :: ")
  5. local p = read()
  6. --Again, change passPath here
  7. local passPath = "passwords"
  8. local f = fs.open(passPath,"r")
  9. local usrs = textutils.unserialize(f.readAll())
  10. f.close()
  11. if not usrs[u] then
  12.   local salt = os.time()  
  13.   usrs[u] = {
  14.         pwd = sha.sha256( p .. salt ),
  15.         salt = salt,
  16.   }
  17.   local f = fs.open(passPath, "w")
  18.   f.write( textutils.serialize( usrs ) )
  19.   f.close()
  20. end
Add Comment
Please, Sign In to add comment