Advertisement
Marlingaming

Global Banking System - Client side Access Program

Sep 14th, 2021 (edited)
1,291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.20 KB | None | 0 0
  1. --standardized Banking System Interaction Script
  2. --this program allows the device it is installed on to interact with the ingame banking system
  3. --this script is for CC Tweaked minecraft 1.16.5
  4.  
  5. AccountBalance = AccountBalance
  6. local tArg = {...}
  7. local Amount = tArg[1]
  8. local AccountID = tArg[2]
  9. local AccountKey = tArg[3]
  10. local TargetAccount = tArg[4]
  11. local Method = tArg[5]
  12. local Serverid = nil
  13. local CryptionCharacter_Base = ["space","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","\n","_"]
  14. local CryptionCharacter_Locked = ["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35"]
  15. EncryptedData = nil
  16.  
  17.  
  18. Transfer()
  19.  
  20. function Transfer()
  21.   rednet.open()
  22.   local id = rednet.lookup(8452,"BankingServer")
  23.   Serverid = id
  24.   if Method == "Details" then
  25.     Encryption_TypeB("r_"..AccountID,"Encrypt")
  26.     rednet.Send(Serverid,EncryptedData,8452)
  27.     rednet.Send(Serverid,AccountID,8452)
  28.     repeat
  29.       local id, message = rednet.receive()
  30.     until id == Serverid
  31.     if message == "failed" or message == "Declined" then
  32.       print("failed to Get Details")
  33.     else
  34.       Amount = message
  35.       Encryption_TypeB(Amount,"Decrypt")
  36.       AccountBalance = EncryptedData
  37.     end
  38.   elseif Method == "Transfer" then
  39.     Encryption_TypeB("t_"..AccountID,"Encrypt")
  40.     rednet.Send(Serverid,EncryptedData,8452)
  41.     rednet.Send(Serverid,AccountID,8452)
  42.     repeat
  43.       local id, message = rednet.receive()
  44.     until id == Serverid
  45.     if message == "failed" or message == "Declined" then
  46.       print("failed Transfer")
  47.     else
  48.       rednet.send(Serverid,TargetAccount,8452)
  49.       repeat
  50.         local id, message = rednet.receive()
  51.       until id == Serverid
  52.       if message == "Account Not Found" then
  53.  
  54.       elseif message == "Account Found" then
  55.         rednet.send(Serverid,Amount,8452)
  56.         repeat
  57.           local id, message = rednet.receive
  58.         until id == Serverid
  59.         if message == "Denied" then
  60.           print("Transfer Denied by Bank")
  61.         else
  62.           print("Transfer Accepted")
  63.           AccountBalance = AccountBalance - Amount
  64.         end
  65.         sleep(10)
  66.       end
  67.     end
  68.   elseif Method == "NewAccount" then
  69.     rednet.send(Serverid,"NewAccount",8452)
  70.     rednet.send(Serverid,AccountID,8452)
  71.     repeat
  72.       local id, message = rednet.receive()
  73.     until id == Serverid
  74.     if message == "Denied" then
  75.       print("Account Denied")
  76.     else
  77.       AccountKey = message
  78.       repeat
  79.         local id, message = rednet.receive()
  80.       until id == Serverid
  81.       local BankName = message
  82.       print("Account ID = "..AccountID)
  83.       print("Account Key = "..AccountKey)
  84.       print("Bank Name = "..BankName)
  85.       if TargetAccount == "n" then
  86.         print("Details not saved due to device not allowed to save Account")
  87.       else
  88.         local file = fs.open(TargetAccount,"w")
  89.         file.writeLine(AccountID)
  90.         file.writeLine(AccountKey)
  91.         file.writeLine(BankName)
  92.         file.writeLine(os.date(IRL))
  93.         file.close()
  94.         print("Account Details saved to local file")
  95.       end
  96.       sleep(15)
  97.     end
  98.   end
  99. end
  100.  
  101. function Encryption_TypeB(data,mode)
  102.   data = string.lowerCase(data)
  103.   local Result = ""
  104.   if mode == "Encrypt" then
  105.     Result = "B_"
  106.     for i = 1, #data.bytes do
  107.       local n = 1
  108.       for n = 1, #CryptionCharacter_Base do
  109.         if substring(data,i,i) == CryptionCharacter_Base[n] then
  110.           Result = Result..CryptionCharacter_Locked[n+AccountKey]
  111.         end
  112.       end
  113.     end
  114.     EncryptedData = Result
  115.   elseif mode == "Decrypt" then
  116.     Result = ""
  117.     for i = 1, #data.bytes do
  118.       local n = 1
  119.       for n = 1, #CryptionCharacter_Base do
  120.         if substring(data,i,i) == CryptionCharacter_Locked[n] then
  121.           if CryptionCharacter_Base[n-AccountKey] == "space" then
  122.             Result = Result.." "
  123.           else
  124.             Result = Result..CryptionCharacter_Base[n-AccountKey]
  125.           end
  126.         end
  127.       end
  128.     end
  129.     EncryptedData = Result
  130.   end
  131. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement