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

[Api] Smigolpol's Password System[V1.2]

Started by smigolpol, 23 December 2012 - 08:17 AM
smigolpol #1
Posted 23 December 2012 - 09:17 AM
Maybe it's not very original idea, but I think It can be useful.

The API


SPS is a system to set, remove and force password anytime you want. Not much more I can tell about it…

Functions:
SpoilersetPassword(text) -Sets the main password, overrides the last main password.
addPassword(text) -Adds an optional password, if you add 5 passwords, user can enter any of them to pass. Idea by Mibac138
removePassword() -Removes all passwords
security() -Forces user to enter the main or any of the optional passwords

Pastebin install:
pastebin get Lx8enqbA sps


Example use:
Protected HelloWorld:
os.loadAPI("sps")

sps.setPassword("yourpassword")
sps.security()
print("Hello world!")   --This line will only work if the password is correct

Force use to enter all your passwords:
os.loadAPI("ps")

local list = {
"thecakeisalie",
"ilikecookies",
"passwordnumber3",
"notapassword",
}

for i = 1, #list do
	ps.setPassword(list[i])
	ps.security()
end

term.setTextColor(colors.green)
print("You did it! :D/>/>")
sleep(3)
term.clear()

Features:
  • Universality
  • Color support
  • Multiple use without any errors
Change log:
Spoiler1.1 -Protected program from terminating it.
1.2 -Added addPassword function. Now you can have multiple passwords at the same time.

Thanks for reading! I hope you'll like it.
Oct125 #2
Posted 23 December 2012 - 11:06 AM
?
Bubba #3
Posted 23 December 2012 - 11:06 AM
Err… post fail?
PixelToast #4
Posted 23 December 2012 - 11:31 AM
-snip-
smigolpol #5
Posted 24 December 2012 - 09:42 PM
-
smigolpol #6
Posted 26 December 2012 - 11:58 PM
The thread has been edited. Try it now…
rick3333 #7
Posted 14 January 2013 - 10:40 PM
this api is epic. I used it to create a double lock program it is 10 lines
smigolpol #8
Posted 17 January 2013 - 06:18 AM
this api is epic. I used it to create a double lock program it is 10 lines
Sorry for late reply, but thanks!
mibac138 #9
Posted 17 January 2013 - 06:56 AM
Preety cool! :)/>

I think you are from Poland is that right? ;)/>
smigolpol #10
Posted 17 January 2013 - 10:59 PM
I think you are from Poland is that right? ;)/>
Yes. That's right. ;)/>
And this is just my first API ever. So I didn't think it can get a positive opinion… But anyway seems like it can be useful.
mibac138 #11
Posted 20 January 2013 - 08:55 AM
:)/>
NeverCast #12
Posted 22 January 2013 - 05:55 PM
Under function security(), put

local pe = os.pullEvent
os.pullEvent = os.pullEventRaw

then at the bottom put

os.pullEvent = pe

This prevents people terminating the program.

You might also want to use a while loop instead of recursive calling the checkPassword function, to prevent stack overflow.

Either way, It's very good! Well done.
smigolpol #13
Posted 22 January 2013 - 11:55 PM
Thanks for hints and corrections! I wasn't actually going to edit it any more, but I can make a new version when I'll have some time.

You might also want to use a while loop instead of recursive calling the checkPassword function, to prevent stack overflow.
No, this method is good for me, because I can precisely define when the method should loop and when it should end. Well, for now it doesn't overflow, I'll think about it then.
theoriginalbit #14
Posted 23 January 2013 - 12:02 AM
Well, for now it doesn't overflow, I'll think about it then.
Well if it hits 255 then it will overflow so…
smigolpol #15
Posted 24 January 2013 - 04:37 AM
I edited this topic to version 1.2.
The title should be:
[API] Smigolpol's Password System[v1.2]

But the editor doesn't let me save it like that… :huh:/> :mellow:/>