Advertisement
antl1on

Install RSA_Encrypt Lib for CC:Tweaked (ComputerCraft)

May 26th, 2024 (edited)
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. function initBigNumInstall()
  2.     if fs.exists(inst_folder.."BigNum.lua") then
  3.         local input = ""
  4.         term.write("BigNum.lua already exists. Overwrite?(y/n): ")
  5.         input = read()
  6.         while (input ~= "y") and input ~= "Y" and input ~= "n" and input ~= "N" do
  7.             term.write("Invalid option. Input \"y\" or \"n\": ")
  8.             input = read()
  9.         end
  10.         if input == "y" or input == "Y" then
  11.             fs.delete(inst_folder.."BigNum.lua")
  12.             installBigNum()
  13.         end
  14.     else
  15.         installBigNum()
  16.     end
  17. end
  18.  
  19. function installBigNum()
  20.     shell.run("wget https://raw.githubusercontent.com/ennorehling/euler/master/BigNum.lua "..inst_folder.."BigNum.lua")
  21.     os.sleep(0.5)
  22.     local bignum_file = fs.open(inst_folder.."BigNum.lua","a")
  23.     bignum_file.write("\nreturn BigNum")
  24.     bignum_file.close()
  25. end
  26.  
  27. function installRSA()
  28.     if fs.exists(inst_folder.."RSA.lua") then
  29.         local input = ""
  30.         term.write("RSA.lua already exists. Overwrite?(y/n): ")
  31.         input = read()
  32.         while (input ~= "y") and input ~= "Y" and input ~= "n" and input ~= "N" do
  33.             term.write("Invalid option. Input \"y\" or \"n\": ")
  34.             input = read()
  35.         end
  36.         if input == "y" or input == "Y" then
  37.             fs.delete(inst_folder.."RSA.lua")
  38.             shell.run("pastebin get BckQ1JyV "..inst_folder.."RSA.lua")
  39.         end
  40.     else
  41.         shell.run("pastebin get BckQ1JyV "..inst_folder.."RSA.lua")
  42.     end
  43. end
  44.  
  45. term.write("Installation Folder?: ")
  46. inst_folder = read()
  47. if inst_folder:sub(#inst_folder,#inst_folder) ~= "/" then
  48.     inst_folder = inst_folder.."/"
  49. end
  50.  
  51. initBigNumInstall()
  52. installRSA()
  53.  
  54. term.setTextColor(colors.green)
  55. print("Installation finished successfully. Press any key to close this installer")
  56. os.pullEvent("key")
  57. term.setTextColor(colors.white)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement