Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
3

How do you type letters and they appear as asterisks?

Python 3

Im trying to make a login page that automatically prints whatever is typed in asterisks.

3 years ago
You are viewing a single comment. View All
2

in python:

from prompt_toolkit import prompt prompt('enter in password: ', is_password=True)
3 years ago
1

@TaylorLiang
Thanks, if i wanted to make it so if the password is the one i have chosen, the program continues.

3 years ago
2

@AlexVasilkovsk1

do this. You will have to encrypt your password to a SHA256 hash though

import hashlib from prompt_toolkit import prompt def encrypt(text): sha_sig = \ hashlib.sha256(text.encode()).hexdigest() return sha_sig if encrypt(prompt('password: ', is_password=True)) == 'the sha256 hash': "do the thing you want to do"
3 years ago
1

@TaylorLiang
Ok I have done this, what is the variable for the password tho

Also pardon my lack of knowledge im new to coding.

3 years ago
1

@AlexVasilkovsk1
replace the sha256 hash with the hash for you password. use this website, and the output will be the sha256 hash

3 years ago
1

@TaylorLiang

from prompt_toolkit import prompt
import hashlib

def encrypt(text):
sha_sig =
hashlib.sha256(text.encode()).hexdigest()
return sha_sig

if encrypt(prompt('password: ', is_password=True)) == 'the sha256 hash':
"b3fa55f98fcfcaf6a15a7c4eb7cdd1b593693d3fef2fb7aec3b6768fd7c6a4ce"

print("hello")

Doesnt work?

the print("hello") is indented btw

3 years ago
1

@AlexVasilkovsk1
you misunderstood me.
replace your if statment with this:

if encrypt(prompt('password: ', is_password=True)) == 'b3fa55f98fcfcaf6a15a7c4eb7cdd1b593693d3fef2fb7aec3b6768fd7c6a4ce': print("Hello")

This is the corrected code

3 years ago
1

@TaylorLiang
Works great, ty for the help.

3 years ago