BananeMan

Client

Sep 22nd, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. --*****************************
  2. --********BANQUE CLIENT********
  3. --*****************************
  4.  
  5. --Déclaration des variables
  6. user = ""
  7. pass = ""
  8. idserver = 0
  9. whilef = false
  10. --rondane = "/disk/rednet"
  11. publickey = ""
  12. crypt = "/disk/crypto"
  13. os.loadApi(crypt)
  14. --os.loadAPI(rondane)
  15. -- Fin des déclaration des variables
  16. function keyretriver()
  17. idserver = rednet.lookup("2banque", "server")
  18. local messagea = {action = "keyretrive"}
  19. local omg = textutils.serialize(messagea)
  20. if idserver == nil then
  21. print("La connection n'a pas plus être établie")
  22. print("Redémarage")
  23. sleep(2)
  24. os.reboot()
  25. else
  26. rednet.send(idserver, omg, "superproto")
  27. end
  28.  
  29. local disable = true
  30. while disable do
  31. local si, mess, distance = rednet.receive()
  32. if si == idserver then
  33. publickey = mess
  34. disable = false
  35. return publickey
  36. end
  37. end
  38. end
  39. function interfac()
  40. print("Connection au serveur banquaire")
  41. rednet.open("back")
  42. keyretriver()
  43. print("Banque interface")
  44. print("Entrée votre nom d'utilisateur:")
  45. user = read()
  46. print("Entrée votre mot de passe")
  47. pass = read("*")
  48. print("Connection en cours")
  49. conn()
  50. end
  51.  
  52. function conn()
  53. local logintable = {action = "login", User = user, Pass = pass, id = os.getComputerID()}
  54. login = textutils.serialize(logintable)
  55. idserver = rednet.lookup("2banque", "server")
  56. logincrypt = crypto.encrypt(table, publickey)
  57. rednet.send(idserver, login, "superproto")
  58. while whilef == false do
  59. senderid, message, disance = rednet.receive()
  60. if senderid == idserver then
  61. mesge = textutils.unserialize(message)
  62. if mesge.action == "login" and mesge.user == user then
  63. whilef = True
  64. if mesge.response == "yes" then
  65. print("Bravo !")
  66. else
  67. print("Mauvais identifiant")
  68. break
  69. end
  70. end
  71. end
  72. end
  73. whilef = false
  74. end
  75.  
  76. interfac()
Add Comment
Please, Sign In to add comment