Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
DemolitionDerby

Password protected computer

Question

Hi,

I have looked around for a way to do it but I have not find anything about it.

I would like to know if it is possible to password protect a computer so that it asks for either a username and a password or simply a password.

Also, is it possible to remove the possibility for the user to terminate the program using CTRL-ALT-C?

 

Thanks!

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Is a simple example.

To nobody could know the password, you need to add hashing.

local event = require('event')
local term = require('term')
local gpu = require('component').gpu
local W, H = gpu.getResolution()
local color1, color2 = 0x00FF00, 0xFF0000
local password = '123456789' -- needed hash function, for most security

event.shouldInterrupt = function() return false end -- blocking Ctrl+Alt+C
event.shouldSoftInterrupt = function() return false end -- blocking Ctrl+C

gpu.setForeground(color1)
while true do
  term.clear()
  term.setCursor(W/2-10, H/2)
  term.write('PASSWORD: ')
  local input = term.read(_,_,_,'*'):sub(1, -2)
  if input == password then
    term.clear()
    term.setCursor(1, 1)
    gpu.setForeground(0xFFFFFF)
    os.exit()
  else
    term.clear()
    gpu.setForeground(color2)
    term.setCursor(W/2-6, H/2)
    term.write('ACCESS DENIED')
    gpu.setForeground(color1)
    os.sleep(3)
  end
end

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.