Last active
April 20, 2020 18:42
-
-
Save somehibs/f20a470c2a0d7b2902442a8da56894f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use this to generate a password, then replace it in .homeassistant/.storage/auth_provider.homeassistant | |
import bcrypt, base64 | |
new_password="password" | |
def hash_password(password: str, for_storage: bool = False) -> bytes: | |
"""Encode a password.""" | |
hashed: bytes = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12)) | |
if for_storage: | |
hashed = base64.b64encode(hashed) | |
return hashed | |
print(hash_password(new_password, True)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment