File size: 559 Bytes
c8a8b27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""Generate a bcrypt hash for a password, to paste into auth_config.yaml.

Usage:
    python hash.py
    > Password to hash: ********
    <prints the hash>

Then replace the plain-text `password:` value in auth_config.yaml with the hash.
"""
import getpass

import streamlit_authenticator as stauth

if __name__ == "__main__":
    pw = getpass.getpass("Password to hash: ")
    try:
        hashed = stauth.Hasher([pw]).generate()[0]      # older API
    except Exception:
        hashed = stauth.Hasher.hash(pw)                 # newer API
    print(hashed)