Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.50 KB | None | 0 0
  1. --Code to SHA-256 it
  2. local g=string.gsub --sha256=loadstring(g(g(g(g(g(g(g(g('Sa=XbandSb=XbxWSc=XlshiftSd=unpackSe=2^32SYf(g,h)Si=g/2^hSj=i%1Ui-j+j*eVSYk(l,m)Sn=l/2^mUn-n%1VSo={0x6a09e667Tbb67ae85T3c6ef372Ta54ff53aT510e527fT9b05688cT1f83d9abT5be0cd19}Sp={0x428a2f98T71374491Tb5c0fbcfTe9b5dba5T3956c25bT59f111f1T923f82a4Tab1c5ed5Td807aa98T12835b01T243185beT550c7dc3T72be5d74T80deb1feT9bdc06a7Tc19bf174Te49b69c1Tefbe4786T0fc19dc6T240ca1ccT2de92c6fT4a7484aaT5cb0a9dcT76f988daT983e5152Ta831c66dTb00327c8Tbf597fc7Tc6e00bf3Td5a79147T06ca6351T14292967T27b70a85T2e1b2138T4d2c6dfcT53380d13T650a7354T766a0abbT81c2c92eT92722c85Ta2bfe8a1Ta81a664bTc24b8b70Tc76c51a3Td192e819Td6990624Tf40e3585T106aa070T19a4c116T1e376c08T2748774cT34b0bcb5T391c0cb3T4ed8aa4aT5b9cca4fT682e6ff3T748f82eeT78a5636fT84c87814T8cc70208T90befffaTa4506cebTbef9a3f7Tc67178f2}SYq(r,q)if e-1-r[1]<q then r[2]=r[2]+1;r[1]=q-(e-1-r[1])-1 else r[1]=r[1]+qVUrVSYs(t)Su=#t;t[#t+1]=0x80;while#t%64~=56Zt[#t+1]=0VSv=q({0,0},u*8)fWw=2,1,-1Zt[#t+1]=a(k(a(v[w]TFF000000),24)TFF)t[#t+1]=a(k(a(v[w]TFF0000),16)TFF)t[#t+1]=a(k(a(v[w]TFF00),8)TFF)t[#t+1]=a(v[w]TFF)VUtVSYx(y,w)Uc(y[w]W0,24)+c(y[w+1]W0,16)+c(y[w+2]W0,8)+(y[w+3]W0)VSYz(t,w,A)SB={}fWC=1,16ZB[C]=x(t,w+(C-1)*4)VfWC=17,64ZSD=B[C-15]SE=b(b(f(B[C-15],7),f(B[C-15],18)),k(B[C-15],3))SF=b(b(f(B[C-2],17),f(B[C-2],19)),k(B[C-2],10))B[C]=(B[C-16]+E+B[C-7]+F)%eVSG,h,H,I,J,j,K,L=d(A)fWC=1,64ZSM=b(b(f(J,6),f(J,11)),f(J,25))SN=b(a(J,j),a(Xbnot(J),K))SO=(L+M+N+p[C]+B[C])%eSP=b(b(f(G,2),f(G,13)),f(G,22))SQ=b(b(a(G,h),a(G,H)),a(h,H))SR=(P+Q)%e;L,K,j,J,I,H,h,G=K,j,J,(I+O)%e,H,h,G,(O+R)%eVA[1]=(A[1]+G)%e;A[2]=(A[2]+h)%e;A[3]=(A[3]+H)%e;A[4]=(A[4]+I)%e;A[5]=(A[5]+J)%e;A[6]=(A[6]+j)%e;A[7]=(A[7]+K)%e;A[8]=(A[8]+L)%eUAVUY(t)t=t W""t=type(t)=="string"and{t:byte(1,-1)}Wt;t=s(t)SA={d(o)}fWw=1,#t,64ZA=z(t,w,A)VU("%08x"):rep(8):format(d(A))V',"S"," local "),"T",",0x"),"U"," return "),"V"," end "),"W","or "),"X","bit32."),"Y","function "),"Z"," do "))()
  3.  
  4. function clearScreen()
  5. term.clear()
  6. term.setCursorPos(1,1)
  7. end
  8.  
  9. function loggedOn(username, password, balance, modem)
  10. while true do
  11. clearScreen()
  12. showTitle(username, balance)
  13. print("1 - Pay another user")
  14. print("2 - Deposit")
  15. print("3 - Withdraw")
  16. print("4 - View spending log")
  17. print("5 - Log Out")
  18. print("")
  19. write("Action> ")
  20. action = read()
  21. if action == "1" then
  22. payScreen(username, password, balance, modem)
  23. elseif action == "2" then
  24.  
  25. elseif action == "3" then
  26.  
  27. elseif action == "4" then
  28.  
  29. elseif action == "5" then
  30. return
  31. end
  32. end
  33. end
  34.  
  35. function showTitle(username, balance)
  36. print(" The Bank Of Sanctuary")
  37. print("---------------------------------------------------")
  38. print("Acount: "..username.." Balance: $"..balance)
  39. print("---------------------------------------------------")
  40. end
  41.  
  42. function viewLog(username, password, balance, modem)
  43. clearScreen()
  44. showTitle(username, balance)
  45. return;
  46. end
  47.  
  48. function userExists(username)
  49.  
  50. local modem = peripheral.wrap("back")
  51. modem.transmit(1,1,"balance`"..username.."`password1234")
  52.  
  53. modem.open(1)
  54. local _, side, freq, rfreq, message = os.pullEvent("modem_message")
  55. if message == "404" then
  56. return false
  57. end
  58. return true
  59. end
  60.  
  61. function payScreen(username, password, balance, modem)
  62. clearScreen()
  63. showTitle(username, balance)
  64. write("Username to pay: ")
  65. payee = read()
  66. write("Amount to pay: $")
  67. amount = read()
  68. if amount > balance then
  69. clearScreen();
  70. difference = amount - balance;
  71. print("You do not have enough money to pay, you need $"..difference.." more!")
  72. os.sleep(4)
  73. elseif userExists(payee) == false then
  74. --Thats not a user!
  75. clearScreen()
  76. print(payee.." is not a valid user!")
  77. os.sleep(4)
  78. else
  79. --Update graphical balance
  80. balance = balance - amount
  81. modem.transmit(1,1,"pay`"..username.."`"..password.."`"..payee.."`"..amount)
  82. end
  83. return;
  84. end
  85.  
  86. while true do
  87. clearScreen()
  88. print("Welcome to The Bank!")
  89. print("Press 1 for a new user")
  90. print("Press 2 for an existing user")
  91. print("")
  92. write("Key> ")
  93.  
  94. key = read()
  95. local modem = peripheral.wrap("back")
  96. if key == "1" then
  97. --user wants to create a new account
  98. clearScreen()
  99. print("Register")
  100. write("Username: ")
  101. username = read()
  102. clearScreen()
  103. print("Register")
  104. write("Password: ")
  105. pssw = read("*")
  106. --Hash password
  107. password = sha256(pssw)
  108. pssw = ""
  109. print("Waiting for server...")
  110. modem.transmit(1,1,"register`"..username.."`"..password)
  111. modem.open(1)
  112. local _, side, freq, rfreq, message = os.pullEvent("modem_message")
  113. if messsage == "409" then
  114. print("This user is already registered!")
  115. else
  116. print("User "..username.." registered!")
  117. end
  118. os.sleep(4)
  119. elseif key == "2" then
  120. --user just wants to login
  121. clearScreen()
  122. print("Login")
  123. write("Username: ")
  124. username = read()
  125. clearScreen()
  126. print("Login")
  127. write("Password: ")
  128. pssw = read("*")
  129. password = sha256(pssw)
  130. clearScreen()
  131. modem.transmit(1,1,"balance`"..username.."`"..password)
  132.  
  133. modem.open(1)
  134. local _, side, freq, rfreq, message = os.pullEvent("modem_message")
  135. if message == "403" then
  136. print("Incorrect password!")
  137. else if message == "404" then
  138. print("There is no user called "..username.."!")
  139. else
  140. loggedOn(username,password,message, modem)
  141. clearScreen()
  142. print("Logged out!")
  143. end
  144. os.sleep(2)
  145. end
  146. end
  147. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement