BananeMan

Untitled

Sep 24th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 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 = "keyretrive"
  19. if idserver == nil then
  20. print("La connection n'a pas plus être établie")
  21. print("Redémarage")
  22. sleep(2)
  23. os.reboot()
  24. else
  25. rednet.send(idserver, messagea, "superproto")
  26. end
  27.  
  28. local disable = true
  29. while disable do
  30. local si, mess, distance = rednet.receive()
  31. if si == idserver then
  32. publickey = mess
  33. disable = false
  34. return publickey
  35. end
  36. end
  37. end
  38. function interfac()
  39. print("Connection au serveur banquaire")
  40. rednet.open("back")
  41. keyretriver()
  42. print("Banque interface")
  43. print("Entrée votre nom d'utilisateur:")
  44. user = read()
  45. print("Entrée votre mot de passe")
  46. pass = read("*")
  47. print("Connection en cours")
  48. conn()
  49. end
  50.  
  51. function conn()
  52. local logintable = {action = "login", User = user, Pass = pass, id = os.getComputerID()}
  53. login = textutils.serialize(logintable)
  54. idserver = rednet.lookup("2banque", "server")
  55. logincrypt = crypto.encrypt(login, publickey)
  56. rednet.send(idserver, login, "superproto")
  57. while whilef == false do
  58. senderid, message, disance = rednet.receive()
  59. if senderid == idserver then
  60. mesge = textutils.unserialize(message)
  61. if mesge.action == "login" and mesge.user == user then
  62. whilef = True
  63. if mesge.response == "yes" then
  64. print("Vous êtes connectée !")
  65. sleep(2)
  66. maininterface()
  67.  
  68. else
  69. print("Mauvais identifiant")
  70. break
  71. end
  72. end
  73. end
  74. end
  75. whilef = false
  76. end
  77.  
  78. function maininterface()
  79. money = 0
  80. term.clear()
  81. term.setCursorPos(1,1)
  82. x,y = term.getSize()
  83. paintutils.drawFilledBox(1,1,x,y, colors.lightGray)
  84. paintutils.drawLine(1,1,x,1, colors.gray)
  85. term.setCursorPos(1,1)
  86. term.write("Menu de la banque")
  87. paintutils.drawPixel(x, 1, colors.red)
  88. term.setCursorPos(x,1)
  89. term.write("X")
  90. term.setCursorPos(1,2)
  91. term.write("Vous avez,"money)
  92.  
  93. --Création des boutton
  94. paintutils.drawFilledBox(1,3,x:4,y, colors.green)
  95. --Actions menu
  96. end
  97.  
  98. interfac()
Add Comment
Please, Sign In to add comment