PreHashing passwords

Hello!

I am kind of stuck in this phase: I cannot prehash passwords using guides found in different blog -posts. Can you give me some link to working how to -which works. I have version Streamlit, version 1.28.2 … Thanks in advance !

Hi @petri, welcome to the forum!

Can you share a bit more about:

  • Why you need to pre-hash passwords? (is this for streamlit-authenticator?)
  • What you have tried previously, and what happened when you tried them (was there an error message?)

If you’re looking for the way streamlit-authenticator does it, it works like this (see Streamlit-Authenticator/streamlit_authenticator/utilities/hasher.py at main · mkhorasani/Streamlit-Authenticator · GitHub):

import streamlit as st
from datetime import datetime
import bcrypt

password = st.text_input("Password", type="password")
hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt()).decode()
st.write("Hashed:")
st.text(hashed)

You can see it in action here:

Hello and thank you very much ! Yes I use streamlit_auth … and it’s quite slow If passwords are not prehashed and that’s why I search solution for that. I try your method and hope it helps !