from . import base
from . import logs
+from . import misc
from .decorators import *
The new passphrase is returned to be sent to the user (once).
"""
# Generate a random string with 40 chars.
- passphrase = generate_random_string(length=40)
+ passphrase = misc.generate_random_string(length=40)
# Create salted hash.
passphrase_hash = generate_password_hash(passphrase)
return True
-# A list of possible random characters.
-random_chars = string.ascii_letters + string.digits
-
-def generate_random_string(length=16):
- """
- Return a string with random chararcters A-Za-z0-9 with given length.
- """
- return "".join([random.choice(random_chars) for i in range(length)])
-
def generate_password_hash(password, salt=None, algo="sha512"):
"""
This function creates a salted digest of the given password.
"""
# Generate the salt (length = 16) of none was given.
if salt is None:
- salt = generate_random_string(length=16)
+ salt = misc.generate_random_string(length=16)
# Compute the hash.
# <SALT> + <PASSWORD>
#!/usr/bin/python
-
-
import hashlib
import os
+import random
import re
+import string
import tarfile
from .constants import *
+# A list of possible random characters.
+random_chars = string.ascii_letters + string.digits
+
+def generate_random_string(length=16):
+ """
+ Return a string with random chararcters A-Za-z0-9 with given length.
+ """
+ return "".join([random.choice(random_chars) for i in range(length)])
+
def format_size(s):
units = ("B", "k", "M", "G", "T")
#!/usr/bin/python
from . import base
-from . import users
+from . import misc
from .decorators import *
The user is not checked and it is assumed that the user exists
and has the right to log in.
"""
- session_id = users.generate_random_string(48)
+ session_id = misc.generate_random_string(48)
return self._get_session("INSERT INTO sessions(session_id, user_id, address, user_agent) \
VALUES(%s, %s, %s, %s) RETURNING *", session_id, user.id, address, user_agent)