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

Sinelock v1.3 - SHA256 hashing, multiple passwords, key cards...

Started by LDDestroier, 14 April 2016 - 04:34 PM
LDDestroier #1
Posted 14 April 2016 - 06:34 PM
It's everything I could ever want in a lock…
It's got so many features, man. So many features…

SINELOCK v1.3



pastebin get XDgeSDTq sinelock
std pb XDgeSDTqs sinelock
std ld sinelock sinelock

I call it 'Sinelock' because while you enter your password, it's shows a beautiful sinewave animation (that I tried my best to optimize)! YAY!

Syntax:

sinelock   --Open the lock screen.
sinelock addpass <password>   --Adds a new password to accept.
sinelock keymake <password>   --Puts a password on a disk or pocket computer.

Features:
+Uses SHA256 hashing w/ salt
+Allows for multiple passwords (either enter one of many, or enter all in order)
+Can use disks as key cards
+Prevents termination (duh)
+Works as computer lock OR door lock

Config options: (in program, not separate config file)
Spoiler

local terminateMode = 2				--0 enables termination, 1 blocks it, 2 provides a taunting screen.
local passFile = ".sl_password"		--The ABSOLUTE path of the password file.
local saltFile = ".sl_salt"			--The ABSOLUTE path of the salt file.
local characterLimit = 1024			--The cap of characters at the read() prompt. Set this to prevent crashes.
local runProgram = ""				--Set to something to run it when correct, and not using doors.
local dahChar = "*"					--The character used to hide characters when typed.
local doKeyCards = true				--Whether or not the lock also accepts keycards (floppy disks) as well as passwords.
local doEjectDisk = false 		   --Whether or not to eject a keycard after it's accepted, just to speed things up a bit.
local doorSides = {}				--If it has anything, the lock will open the doors instead of unlocking the PC.
local doInvertSignal = false		--If true, it will invert the redstone signal of the door, in case you need to.
local doShowDoorSides = true		--If true, will show the door sides being opened. Set to false if you are paranoid.
local beWavey = true				--Whether or not to animate the sine wave.
local readYpos = scr_y-2			--The Y position of the read() prompt
local requireAllPasswords = false	--Whether or not the lock asks for ONE of the multiple passwords, or ALL of them in order.
local badlength = 4					--The length in seconds that you have to wait to try again.
local goodlength = 6				--The length in seconds that doors will stay open.
local sineFrameDelay = 0.15			--The amount of time between sine animation frames. Tradeoff of purty vs performance.

Screenshots:
Spoiler
The main screen, showcasing the duel-layered sine wave animation. The "P1" is if you have more than one password.


You can load passwords onto a disk as a keycard!
Edited on 11 April 2017 - 08:58 PM
H4X0RZ #2
Posted 14 April 2016 - 07:58 PM
You took your screensaver and turned it into a lock? Interesting!
Creator #3
Posted 14 April 2016 - 08:02 PM
It is called sinelock because the screensaver is like a sine wave, right?
LDDestroier #4
Posted 14 April 2016 - 08:03 PM
It is called sinelock because the screensaver is like a sine wave, right?

Yup.
FUNCTION MAN! #5
Posted 15 April 2016 - 01:44 AM
sha256 is not encryption, it's cryptographic digest / hashing.
LDDestroier #6
Posted 15 April 2016 - 04:04 AM
sha256 is not encryption, it's cryptographic digest / hashing.

Damn! I knew I messes something up. Even if it was phrasing.
randomdude999 #7
Posted 19 May 2016 - 01:31 PM
I know this is a bit old, but the REAL way to do removable media auto unlock is with one-time pads. You regenerate the pads every time the computer is unlocked. If you know Python, then you can check out http://winappdbg.sou...net/blog/otp.py.

Hint: A true random generator is at https://www.fourmilab.ch/hotbits/. To get 2048 random bits, use https://www.fourmila...Hotbits?fmt=bin. Wait, that has rate limiting. Better just use math.random.
Edited on 19 May 2016 - 12:38 PM
Dragon53535 #8
Posted 19 May 2016 - 05:26 PM
I don't see how that is applicable here at all. His system doesn't rely on removable media. Except for floppy disks in which all they have is the hashed password set into a file.
LDDestroier #9
Posted 04 June 2016 - 01:23 AM
Cool new update!
+Added new config option 'dahChar', which is the character that is shown instead of the password when being typed ("********" instead of "password")
*Changed 'preventTermination' to 'terminationMode'. If 0, allows termination. If 1, disallows it. If 2, it shows a funny message like my previous lock.
*Changed format for hashed password file. A salt has been added, and newlines were stripped.
*Fixed floppy disk passwords not working
*Since last update, fixed flickering issues


If it has any problems (like, real problems that immediately cause issues), comment away! Or don't…y'know…

UPDATE: I changed the way salts work to how they should work. Before it was derived from the password, but now it's 128 random characters.
Edited on 04 June 2016 - 11:26 PM
LDDestroier #10
Posted 06 June 2016 - 09:01 PM
I made a new update! Ain't that the darnedest thing!

*Fixed some bugs that prevented it from working at all...woops
*Fixed the alternative YOU ARE WRONG or CORRECT message after 10 or more tries.
+Added a palate table, to easily change the colors
+Added different languages, for no raisin.

I've been meaning to add a palate for a while, but never did. Perhaps I should also add a background image to be rendered behind the sines?
Bye. #11
Posted 13 July 2016 - 11:52 PM
I made a new update! Ain't that the darnedest thing!

*Fixed some bugs that prevented it from working at all...woops
*Fixed the alternative YOU ARE WRONG or CORRECT message after 10 or more tries.
+Added a palate table, to easily change the colors
+Added different languages, for no raisin.

I've been meaning to add a palate for a while, but never did. Perhaps I should also add a background image to be rendered behind the sines?

Because I really like this program I created the italian translation for you:

italian = {
  wrong1 = "HAI SBAGLIATO.",
  wrong2 = "HAI SBAGLIATO, COME SEMPRE D'ALTRONDE.",
  right1 = "CORRETTO!",
  right2 = "CORRETTO, FINALMENTE!",
  noTerminate = "Non cercare di terminarmi",
},
Edited on 14 July 2016 - 12:10 AM
LDDestroier #12
Posted 14 July 2016 - 02:37 AM
Because I really like this program I created the italian translation for you:

Oh cool, thanks! Speaking of the different languages, did you try translating the latin for 'noTerminate'?
Bye. #13
Posted 14 July 2016 - 11:37 AM
Because I really like this program I created the italian translation for you:

Oh cool, thanks! Speaking of the different languages, did you try translating the latin for 'noTerminate'?

I'm still not too sure about the grammatical quality of this translation…

latin = {
  wrong1 = "ERRONEIS.",
  wrong2 = "ERRONEIS, UT SEMPER.",
  right1 = "Ius!",
  right2 = "Ius, tandem!",
  noTerminate = "Noli prohibere conantur me",
},
LDDestroier #14
Posted 14 July 2016 - 09:47 PM
Um,I meant translating what I put for 'noTerminate' from Latin to English.
Bye. #15
Posted 14 July 2016 - 09:59 PM
Um,I meant translating what I put for 'noTerminate' from Latin to English.
Oh…. I did it while I was trying to translate from English to Latin, very Latin culture stuff… :lol:/>
LDDestroier #16
Posted 11 April 2017 - 10:55 PM
A new update!
Since KrakenCraft has made good use of sinelock for their doors in a giant round building, I thought it only logical to fix some of the most glaring issues.

+Added 1024 character limit, to halt completely insane password sizes
Change this in the config variable 'characterLimit'
+Optimized sine wave animation -- not only are all writing functions localized, but the delay between frames is 0.15 rather than 0.05.
Change this in the config variable 'sineFrameDelay'
+Increased the termination script size
*Sinelock will now print any errors it may encounter if terminationMode is set to 0.
*Fixed major issue with entering the correct password not registering as correct.

This will probably break your current setup, unless you've got only one password, in which case you're fine with replacing the old sinelock with the new.