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

Touchscreen Monitor PIN Keypad!

Started by Jian, 08 April 2013 - 07:28 PM
Jian #1
Posted 08 April 2013 - 09:28 PM
VERSION 4.9


I'm not sure if this has been done before. If it has, I'd like to see a link to see how mine compares to theirs.
Bug reports appreciated.

PASTEBIN

 http://pastebin.com/xSPb4S3d 

HOW TO USE!
  1. Go to any computer with HTTP API enabled
  2. Type "pastebin get xSPb4S3d startup" (alternatively download it from pastebin and save it as startup on any computer)
  3. Attach a monitor to any side, any size.
  4. (optional) Attach an Iron Note Block to any size
  5. Attach your redstone output to the back
  6. Restart Terminal (Ctrl+R)
  7. Follow On Screen Prompts
  8. Report Bugs, Provide Feedback, Provide Suggestions Please!
To change colors:
Press C !

  1. Terminate the program (Ctrl+T)
  2. Type "edit startup"
  3. Scroll to Lines 22-24 and edit the colors to your liking.
  4. Save (Ctrl, S)
  5. Restart (Ctrl+R)
To change scale while the program is running press "s" on the terminal.

Features
  1. Monitor Touchpad
  2. Sound with MiscPeripherals' Iron NoteBlock (optional)
  3. SHA-256 encryption for your pin! Found Here: http://lua-users.org...reHashAlgorithm
  4. Customizable colors (easy to change now)
  5. Option to censor keypad
Changelog
Spoiler4.8.1
INITIAL RELEASE

4.8.2
- Added keypad censorship
- Changed colors around for greater visibility
- Customizable vertical position

4.8.3
- Fixed the bug allowing you to have 0's in your pin despite the keypad lacking a "0" key.

4.8.4
- Added persistent data. To edit config, terminate program and type "edit pin/data". I will try to make this an easier process eventually.

4.8.5
-Made the configuration easier and added an option to change the PIN


Upcoming
  • Config file (persistent data , very easy to implement, just very late at night right now and i'm going to bed.) (sort of done)
  • Bug Fixes that I already spotted (Report any bugs you notice please :D/> )
  • Automatic monitor scaling
  • easier customization (better setup wizard)
  • more options
  • Zero.
Known Bugs
  • If anyone can get the hash they can get the pin because of readily available rainbow tables
Screenshots:

http://imgur.com/a/SPtmK

Video coming soon if the feedback is positive.
Edited on 13 March 2014 - 04:10 PM
Simox000 #2
Posted 09 April 2013 - 01:33 AM
Awesome! Im going to have this in my base! ;)/>
Easy to use and edit!
Good Work! =D

5/5 Stars! =D
SuicidalSTDz #3
Posted 09 April 2013 - 01:49 AM
I like it when new members make new things. I really like this. Kudos to you ^_^/>
Jian #4
Posted 09 April 2013 - 05:00 AM
Thanks for the feedback guys. I've been reading the forums for a while and into CC since I discovered it in Tekkit. CC is my first programming experience.
Mackan90096 #5
Posted 09 April 2013 - 06:07 AM
You should add the 0
Mackan90096 #6
Posted 09 April 2013 - 06:16 AM
Oh, is it possible to hide the numbers on the monitor with a * ?
ElectricOverride #7
Posted 09 April 2013 - 06:52 AM
Oh, is it possible to hide the numbers on the monitor with a * ?
I havn't looked at the program at all yet so I don't know what you are doing but, you could make it so every time the event passes from a key being pressed on the monitor it prints a * instead of printing the letter.
Mackan90096 #8
Posted 09 April 2013 - 06:54 AM
Yeah. Thats what I want
SuicidalSTDz #9
Posted 09 April 2013 - 08:50 AM
local input = read("*")

This can be used with any character/letter/number
Jian #10
Posted 09 April 2013 - 09:04 AM
You should add the 0

I don't intend to add a '0' key. I intend to make sure you don't make a pin containing a 0.

Oh, is it possible to hide the numbers on the monitor with a * ?

I have added this feature and pushed the first update
simply run the following commands


delete startup
pastebin get SDvHNe61 startup

and then restart your computer again (Ctrl+R)

local input = read("*")

This can be used with any character/letter/number

This doesn't make sense in the context of how I render the page. I don't use read, the program is based on monitor touch events.
SuicidalSTDz #11
Posted 09 April 2013 - 09:14 AM
Oh, I didn't read that carefully. Forget the read("*") code I posted. You would need to do something with tables, which I don't really feel like explaining at the current moment. However, if you already use tables to render your screen, then this would be easier for me to explain/make a script.
Jian #12
Posted 09 April 2013 - 09:50 AM
I have already added the feature in question and have added a new configuration variable at the top of the program to toggle it
SuicidalSTDz #13
Posted 09 April 2013 - 09:58 AM
I have already added the feature in question and have added a new configuration variable at the top of the program to toggle it
Wow, you're new and smart :)/> I like you already ^_^/>

Good job, i'm really liking this.
Jian #14
Posted 09 April 2013 - 12:31 PM
4.8.4
- Added persistent data. To edit config, terminate program and type "edit pin/data". I will try to make this an easier process eventually.
Amunak #15
Posted 19 June 2013 - 03:00 PM
This thing is epic. Thanks!
Beastly #16
Posted 19 June 2013 - 07:38 PM
Instead of removing the 0 bug, why not add a "0" button?
KeeganDeathman #17
Posted 11 July 2013 - 02:15 AM
Mind if I make something like this? It's a keyboard program for an adventure map I'm working on.
logwet #18
Posted 13 July 2013 - 03:00 AM
what does the "COR" button on the monitor do?
NOTUSEDPLEASEDELETE #19
Posted 16 August 2013 - 04:58 PM
what does the "COR" button on the monitor do?
Can't remember, but I can remember the colors of the bottom buttons:
Orange: Backspace
Red: Clear
Green: Confirm
NOTUSEDPLEASEDELETE #20
Posted 16 August 2013 - 05:07 PM
And also, this is how to make editing easier:
SpoilerMake a new line of text on the terminal:
'E - Edit config' and make this code if E is pressed:

m.clear()
m.setCursorPos(1,1)
shell.run("edit pin/data")
Because shell.run(<program>, [arguments]) runs that program.
<> = required
[] = optional
Edit: I found a bug:
The new wired modems don't work with this program.
Herophantom #21
Posted 21 August 2013 - 09:33 PM
Here is my verison of the same thing, except I opted to make it small so it can be put out of the way. Its only one monitor, but it works pretty well:

[media]http://youtu.be/gcuINzwYdV0[/media]

Also in that video is my sensor door lock, but that can be for another thread. Here is the code I used for the keypad. I have had it working for about a week now with no problems, so if anyone finds any bugs, please let me know. Also, any pointers on ways I can optimize the code would be nice.

Spoiler

mon = peripheral.wrap("front")
mon2 = peripheral.wrap("top")
local password = {
  digit1 = "*",
  digit2 = "*",
  digit3 = "*",
  digit4 = "*"
}
mon.clear()
mon.setCursorPos(2,1)
mon.setBackgroundColor((colors.red))
mon.write("Reset")function writePad()
  local i = 1
  local x = 2
  local y = 2

  while i <= 9 do
	mon.setBackgroundColor((colors.lime))
	mon.setCursorPos(y,x)
	mon.write(i)
	mon.setCursorPos(y+1, x)
	mon.setBackgroundColor((colors.black))
	mon.write(" ")
	y = y + 2
  
	if y == 8 then
	  y = 2
	  x = x + 1
	end
  
	i = i + 1
  end
end
writePad()mon.setBackgroundColor((colors.black))
function writePass()
  local pass = {
  pass1 = "_",
  pass2 = "_",
  pass3 = "_",
  pass4 = "_"
}
if password.digit1 ~= "*" then
   pass.pass1 = "*"
endif password.digit2 ~= "*" then
   pass.pass2 = "*"
end
if password.digit3 ~= "*" then
   pass.pass3 = "*"
endif password.digit4 ~= "*" then
   pass.pass4 = "*"
end
  mon.setCursorPos(2,5)
  mon.write(pass.pass1..pass.pass2..pass.pass3..pass.pass4)
endwritePass()

local passPos = 1
local mousePosW = 1
local mousePosH = 1function setDigit(digit)
  if passPos == 1 then
	password.digit1 = digit
  end

  if passPos == 2 then
	password.digit2 = digit
  end

  if passPos == 3 then
	password.digit3 = digit
  end

  if passPos == 4 then
	password.digit4 = digit
  end
  passPos = passPos + 1
endfunction checkMousePos()
  if mousePosH == 1 then
	resetPass()
  end
  if mousePosH == 2 then

	if mousePosW == 2 or mousePosW == 3 then
	  setDigit("1")
	end
  
	if mousePosW == 4 or mousePosW == 5 then
	  setDigit("2")
	end
  
	if mousePosW == 6 or mousePosW == 7 then
	  setDigit("3")
	end
  end

  if mousePosH == 3 then

	if mousePosW == 2 or mousePosW == 3 then
	  setDigit("4")
	end
  
	if mousePosW == 4 or mousePosW == 5 then
	  setDigit("5")
	end
  
	if mousePosW == 6 or mousePosW == 7 then
	  setDigit("6")
	end
  end

  if mousePosH == 4 then

	if mousePosW == 2 or mousePosW == 3 then
	  setDigit("7")
	end
  
	if mousePosW == 4 or mousePosW == 5 then
	  setDigit("8")
	end
  
	if mousePosW == 6 or mousePosW == 7 then
	  setDigit("9")
	end
  end

endfunction resetPass()

  password.digit1 = "*"
  password.digit2 = "*"
  password.digit3 = "*"
  password.digit4 = "*"
  passPos = 1
  writePass()
end
while true do
  if passPos == 5 then
	if password.digit1 == "9" and password.digit2 == "5" and password.digit3 == "4" and password.digit4 == "2" then -- this is where the actual password is hardcoded in
	  rs.setOutput("left", true)
	  mon2.setCursorPos(1,1)
	  mon2.clear()
	  mon2.write("Welcome Herophantom") -- change this to whatever message you want
	  sleep(4)
	  rs.setOutput("left", false)
	  resetPass()
	
	else
	  local timer = 3
	  mon2.setTextColor(16384)
	  while timer > 0 do
	  mon2.setCursorPos(1,1)
	  mon2.clear()
	  mon2.write("Unauthorised Access Attempted")
	  sleep(0.5)
	  mon2.setCursorPos(1,1)
	  mon2.clear()
	  sleep(0.5)
	  timer = timer - 1
	end
	  resetPass()
	end  
  end
  mon2.setTextColor(1)
  mon2.setCursorPos(1,1)
  mon2.clear()
  mon2.write("Authorised Personel Only")
  event,p1,p2,p3 = os.pullEvent()

  if event == "monitor_touch" then
	mousePosH = p3
	mousePosW = p2
   checkMousePos()
  endwritePass()
end

At the moment, the password is hard coded and I have plans to change that. Also, I'm planning on adding a bit more feedback on the gui, making it flass green with "access granted" and red with "access denied"

Let me know what you think.
Dreossk #22
Posted 24 December 2013 - 12:05 AM
Hello,

This program is great. the problem is that the hitbox of the buttons is pretty messed up, especially for the first row (1,2,3). Pressing a number sometimes even gives the wrong number. Maybe it's a scale issue? It's not usable in the current state.

Also, putting censor to false doesn't work.

Edit: In fact, none of the changeable options I tried at the beginning work.
Edited on 28 December 2013 - 09:16 PM
kwstoudt #23
Posted 29 December 2013 - 08:48 PM
how to edit pin?
awsmazinggenius #24
Posted 29 December 2013 - 09:50 PM
Hello,

This program is great. the problem is that the hitbox of the buttons is pretty messed up, especially for the first row (1,2,3). Pressing a number sometimes even gives the wrong number. Maybe it's a scale issue? It's not usable in the current state.

Also, putting censor to false doesn't work.

Edit: In fact, none of the changeable options I tried at the beginning work.
That was a giant, 5 month bump.
how to edit pin?
Try editing the program on line 135 and see if that works.
Anavrins #25
Posted 26 January 2014 - 01:10 PM
Unfortunately, SHA-256 is not suitable for 1-5 digits pins, and a simple lookup of the hash on Google will yield the pin,
since there are rainbow tables of 00000 through 99999 on the net.
A way to mitigate this would be to implement a salt, if you need help with that, I can give you a hand, just PM me :)/>

Edit: Sorry for the bump, but I felt that it was necessary to bring this up.
Edited on 26 January 2014 - 12:13 PM
luaCoder #26
Posted 26 January 2014 - 02:28 PM
how did you hack into a computer blocked and protected from access the only way to access it was to break a protected block?
Anavrins #27
Posted 26 January 2014 - 03:18 PM
how did you hack into a computer blocked and protected from access the only way to access it was to break a protected block?
That's not the point of the post, but anyway, you can do that by breaking a protected block and clicking the computer before that protected block respawns.
Jian #28
Posted 13 March 2014 - 05:21 PM
I have released an update for this program. Pease see the change logs in the first post.


Instead of removing the 0 bug, why not add a "0" button?
Added to upcoming features list
what does the "COR" button on the monitor do?
It stands for "correction" and its basically a backspace.
Here is my verison of the same thing…
Let me know what you think.
I think your layout looks really nice. One issue that I'm having with my program is that in order to use it at optimal size (scale 0.5) you need to stack two monitors or you lose the frame.
Hello,

This program is great. the problem is that the hitbox of the buttons is pretty messed up, especially for the first row (1,2,3). Pressing a number sometimes even gives the wrong number. Maybe it's a scale issue? It's not usable in the current state.
Also, putting censor to false doesn't work.
Edit: In fact, none of the changeable options I tried at the beginning work.

Not sure what was going on with the hitboxes. Should only accept hits on the number itself or either of the blank spaces beside the number. Haven't had a chance to test this yet. almost all of the options were broken with the last update. I have fixed it somewhat. anything that isn't in the main config should update with 'edit pin/data'
Unfortunately, SHA-256 is not suitable for 1-5 digits pins, and a simple lookup of the hash on Google will yield the pin,
since there are rainbow tables of 00000 through 99999 on the net.
A way to mitigate this would be to implement a salt, if you need help with that, I can give you a hand, just PM me :)/>

Edit: Sorry for the bump, but I felt that it was necessary to bring this up.
ah yeah that makes sense. But to be fair this is more for show, even with protected blocks and anything else you can think of short of Adventure Mode, I am sure there are 1000 ways to break into this. if you can access the computer you could just Ctrl+T and open the lua console and write 'for _,v in pairs( rs.getSides() ) do rs.setOutput( v , true )'
killorx #29
Posted 19 June 2014 - 09:22 AM
alright so i need to know. is there a way to use a modem to link it to a monitor for far distances (better security basically)
liquidthex #30
Posted 25 June 2014 - 08:29 PM
Hello! Thank you a lot for this program!

I've modified it as you can see in this video:
https://www.youtube....eature=youtu.be

I've changed it to actually do a "secure" PIN authentication against a remote (wired) 2nd computer.
It requests a salted 1-time hash from the pin server and then sends the password hashed against that to the remote side which can then validate it or not.
This simultaneously solves the rainbow table attack, and makes it so the terminal granting/denying access can be placed remote of the terminal for entering the codes.
It also makes it so you can have multiple PIN Terminals but only a single authenticator controlling access, as seen in my video.
I have plans to make the Pin Server program keep logs and display logs to monitors, and to just generally make this nicer.. For now it's too rough to be considered releaseable for other people..
But here's the code if you want to see!

My modified version of your script: http://pastebin.com/1Qqk7c6D
My PIN Server script to run on the other terminal: http://pastebin.com/JHV9wG73

Thank you for your keypad script it's very well written!
Edited on 25 June 2014 - 06:31 PM
jackedup123 #31
Posted 21 July 2014 - 06:46 AM
Thank you, I have been looking everywhere for something like this! I think this will be epic for my base! :D/>
Cookiezi #32
Posted 21 July 2014 - 07:13 PM
If you have the numbers visible then it makes the lock a bit unsecure.
Jian #33
Posted 12 August 2014 - 03:20 AM
alright so i need to know. is there a way to use a modem to link it to a monitor for far distances (better security basically)

Looks like liquidthex has done something better than what you're asking for but

Hello! Thank you a lot for this program!

I've modified it as you can see in this video:
https://www.youtube....eature=youtu.be

I've changed it to actually do a "secure" PIN authentication against a remote (wired) 2nd computer.
It requests a salted 1-time hash from the pin server and then sends the password hashed against that to the remote side which can then validate it or not.
This simultaneously solves the rainbow table attack, and makes it so the terminal granting/denying access can be placed remote of the terminal for entering the codes.
It also makes it so you can have multiple PIN Terminals but only a single authenticator controlling access, as seen in my video.
I have plans to make the Pin Server program keep logs and display logs to monitors, and to just generally make this nicer.. For now it's too rough to be considered releaseable for other people..
But here's the code if you want to see!

My modified version of your script: http://pastebin.com/1Qqk7c6D
My PIN Server script to run on the other terminal: http://pastebin.com/JHV9wG73

Thank you for your keypad script it's very well written!

This makes me pretty happy. I read through your additional code and I enjoy it. It's still hackable though ;)/> . Your plans for the base control system are ambitious and I would recommend scrapping most of what I've done in favour of something that can be more modularized and expanded upon. In my code I have hard coded a lot of things that should not be hard coded.


Thank you, I have been looking everywhere for something like this! I think this will be epic for my base! :D/>

Can't wait to see it, post a video when you're done!

If you have the numbers visible then it makes the lock a bit unsecure.

That's true unless it's in a back part of your base and you know nobody is gonna be around when you're opening it. The whole program is more for design than functionality. The whole thing is super insecure. I'm no goggle or yayhoo or what have you.
Ednigma #34
Posted 07 March 2016 - 03:08 AM
Hey. First off i think this key pad works great. I am using this for a drawbridge door. I have figured out how to invert the redstone signal but i need to be able to activate the door with 2 monitors. What do i have to add to have this work with a monitor to the right of the computer and behind?
TheBlueKingLP #35
Posted 04 March 2017 - 10:02 AM
you should make it "Ask for current password when you want to change password"