Ask coding questions

← Back to all posts
Help with a secure login
AzureScripts (166)

I am trying to password protect my website, where it asks for a username and password before entering.
But is there a way to allow it so that my python script can access the contents and text on the site, but ask for a password with normal users

JoshuaKing1 (71)

You can see my repl You just have to add a field for username. Basically, copy and paste but change ids and titles.

ebest (635)

Now that I can see your program (Stalking skillz (not really)) I see a small problem:

hash_username = hashlib.pbkdf2_hmac('sha256', bytes(username, 'utf-8'), b'salt', 150000)
    hash_password = hashlib.pbkdf2_hmac('sha256', bytes(password, 'utf-8'), b'salt', 150000)

USE SHA512! it's not that important but I like it a lot more.

Also, the text isn't that secure yet. Do you know how to write files?

For your actual question, I need to know where you are running it. If it's on this site I can't help you because I don't know JS. The only way I know of is this site.

YAY. I am very happy in completing my first programming challenge. Maybe it wasn't an official one, but it is a challenge. 20 minutes spent on this.


AzureScripts (166)

@ebest 1. I do know how to write files
2. i am running the login on a .py file on my PC
3. The hashes are stored on a website

ebest (635)

@AzureScripts well there you go. I was thinking of writing a .env file with all the website's actual content, like if you put all the content to be printed out in a module in the middle of a .env file and then made it so that the login module called the module inside of the .env file... a little complicated, but I gave you the answer up there. Can you accept it? Or this one?

AzureScripts (166)

@ebest not exactly what i am looking for.

I am just tryna see if i can make it so that i can have a protected website, which you can't access manually, but allow my script to see inside.

AzureScripts (166)


i have the hashes and stuff to a login on a "hashes.txt".
When i go on there manually, it asks for a Username and Password

When my script goes on it, it can read the data.

ebest (635)

@AzureScripts Are you asking for file READING? Because that isn't hard.

Reading files

AzureScripts (166)

@ebest No... it's not a file... it's on a website...

r = requests.get('')

I am talking about if i can do that ^^^^... but make it work with a password on the site
it isn't that hard to understand.

ebest (635)

@AzureScripts so you have to do
r = requests.get('', password="abc")

ebest (635)

@AzureScripts is that what you want to do? so all the contents cannot be seen by regular people?

ebest (635)

@AzureScripts Ah. That would be, to say the least, complicated. There is a (really really really) complicated way of putting all the encrypted information in a file.

Another solution would be to switch your language to brainf.

ebest (635)

@AzureScripts Python is built to be view able and simple. It's really really hard to encrypt it. Don't try, you'l fail. Sorry!

ArchieMaclean (830)

You would need to add some method of verification, otherwise anyone could just write a script.

AzureScripts (166)

@ArchieMaclean How would i do that though?