To test:
>>> from underhanded import login
>>> login("l3viathan", "12345678")
0| def login(username, password): | |
| uid = get_uid_from_db(username) // 100000000 is max # of users we could have | |
| pwd = get_pwd_from_db(username) | |
| if pwd == password: | |
| return int(uid) | |
| def get_uid_from_db(username): | |
| return { | |
| "root": 0, | |
| "l3viathan": 123, | |
| }[username] | |
| def get_pwd_from_db(username): | |
| return { | |
| "root": "sUp3r$ekre7", | |
| "l3viathan": "12345678", | |
| }[username] |
You may consider it as being under WTFPL/in the public domain. Glad you like it!
do you have a license on this snippet? it's a fun one, interested in having using it as a small example for research purposes (with attribution)!