This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
RainbowCow's profile picture

Sha256 problem with security startup, please help. [SOLVED]

Started by RainbowCow, 30 January 2015 - 02:39 PM
RainbowCow #1
Posted 30 January 2015 - 03:39 PM
Ok, so I've tried to make a security startup, which is impossible to get any password out of, so I found sha256, and tried it, tried to make it into my code. But I keep on getting errors, can someone help me? Thanks in advance.

-- Setup
os.loadAPI("sha")
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.cyan)
os.pullEvent = os.pullEventRaw

-- Define

-- Main code
textutils.slowPrint("Eyax Security", 1500)
sleep(1)
term.clear()
term.setCursorPos(1,1)
while true do
  textutils.slowPrint("Login / Shutdown / Reboot")
  print(" ")
  term.setCursorPos(1,3)
  print("|--------------|")
  term.setCursorPos(1,5)
  term.setCursorPos(1,4)
  print("|")
  term.setCursorPos(16,4)
  print("|")
  term.setCursorPos(1,5)
  print("|--------------|")
  term.setCursorPos(4,4)
  input = string.upper( read() )
  if input == "LOGIN" then
	print(" ")
	term.setCursorPos(1,7)
	print("Please input username to login.")
	write("Username: ")
	username = read()
	print(" ")
	print("Please input password to login.")
	write("Password: ")
	password = read("*")

	 if username == "EyaxJonas88" and sha.sha(password) == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" then
	   print(" ")
	   term.setTextColor(colors.lime)
	   print("Access Granted.")
	   sleep(1)
	   term.setTextColor(colors.yellow)
	   term.clear()
	   term.setCursorPos(1,1)
	   write("Eyax --")
	   break
	  else
		print("Username or password is invalid.")
		sleep(1.7)
		term.clear()
		term.setCursorPos(1,1)
	  end
	elseif input == "SHUTDOWN" then
	  print("Shutting Down...")
	  sleep(1)
	  os.shutdown()
	elseif input == "REBOOT" then
	  print("Rebooting...")
	  sleep(1)
	  os.reboot()
	end
  end
Edited on 30 January 2015 - 04:09 PM
InDieTasten #2
Posted 30 January 2015 - 04:22 PM
What errors?
Dragon53535 #3
Posted 30 January 2015 - 05:08 PM
If you wouldn't mind also posting the API. Since the error might be because of that.
RainbowCow #4
Posted 30 January 2015 - 05:08 PM
Solved, do not reply.

Forgot to remove Local from the sha256 file
so it wasn't an API :P/> its solved ^^
Anavrins #5
Posted 30 January 2015 - 08:13 PM
You'll probably want to also use a salt with your password.
I know that the hash in your code isn't your password, but I do know it's the hash of an empty string ( sha.sha("") )
Searching an unsalted hash on Google will often give you the word it is hashing.
Edited on 30 January 2015 - 07:20 PM