Skip to content

Instantly share code, notes, and snippets.

@somehibs
Last active April 20, 2020 18:42
Show Gist options
  • Save somehibs/f20a470c2a0d7b2902442a8da56894f1 to your computer and use it in GitHub Desktop.
Save somehibs/f20a470c2a0d7b2902442a8da56894f1 to your computer and use it in GitHub Desktop.
# 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