mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
See PEP 328[1] for details. This feature was introduced in Python 2.5 and will become mandatory in Python 3. [1]: http://www.python.org/dev/peps/pep-0328 (imported from commit 7444eeba8a08d5f91b94c7921848f2274979bd76)
22 lines
603 B
Python
22 lines
603 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]
|
|
|
|
def initial_api_key(email):
|
|
|
|
"""Given an email address, returns the initial API key for that account"""
|
|
|
|
digest = hashlib.sha256(settings.INITIAL_API_KEY_SALT + email).digest()
|
|
return base64.b16encode(digest)[:32].lower()
|