Files
zulip/zephyr/lib/initial_password.py
Tim Abbott abd9e4e635 Use proper randomization when generating new API keys.
Previously we were generating API keys deterministically using a hash
of the user's email address; this is clearly not a good long-term
approach.

(imported from commit 14d0c7c9edbc45b3ae1d17a43765ad9726338d4d)
2013-05-29 15:11:24 -04:00

14 lines
367 B
Python

from __future__ import absolute_import
from django.conf import settings
import hashlib
import base64
def initial_password(email):
"""Given an email address, returns the initial password for that account, as
created by populate_db."""
digest = hashlib.sha256(settings.INITIAL_PASSWORD_SALT + email).digest()
return base64.b64encode(digest)[:16]