예제 #1
0
파일: models.py 프로젝트: reduxdj/brubeck
 def set_password(self, raw_passwd):
     """Generates bcrypt hash and salt for storing a user's password. With
     bcrypt, the salt is kind of redundant, but this format stays friendly
     to other algorithms.
     """
     (algorithm, salt, digest) = auth.gen_hexdigest(raw_passwd)
     self.password = auth.build_passwd_line(algorithm, salt, digest)
예제 #2
0
파일: models.py 프로젝트: UXE/brubeck
 def set_password(self, raw_passwd):
     """Generates bcrypt hash and salt for storing a user's password. With
     bcrypt, the salt is kind of redundant, but this format stays friendly
     to other algorithms.
     """
     (algorithm, salt, digest) = auth.gen_hexdigest(raw_passwd)
     self.password = auth.build_passwd_line(algorithm, salt, digest)
예제 #3
0
파일: models.py 프로젝트: B-Rich/brubeck
 def check_password(self, raw_password):
     """Compares raw_password to password stored for user. Updates
     self.last_login on success.
     """
     algorithm, salt, hash = auth.split_passwd_line(self.password)
     (_, _, user_hash) = auth.gen_hexdigest(raw_password, algorithm=algorithm, salt=salt)
     if hash == user_hash:
         self.last_login = curtime()
         return True
     else:
         return False
예제 #4
0
파일: models.py 프로젝트: pombreda/brubeck
 def check_password(self, raw_password):
     """Compares raw_password to password stored for user. Updates
     self.last_login on success.
     """
     algorithm, salt, hash = auth.split_passwd_line(self.password)
     (_, _, user_hash) = auth.gen_hexdigest(raw_password,
                                            algorithm=algorithm, salt=salt)
     if hash == user_hash:
         self.last_login = curtime()
         return True
     else:
         return False
예제 #5
0
import sys
import pymongo

from config import DB_PORT
from auth import gen_hexdigest

if __name__ == '__main__':
    c = connection = pymongo.Connection('localhost', DB_PORT)
    db = c.auth
    users = db.users
    algorithm, salt, encrypted_pswd = gen_hexdigest(str(sys.argv[2]))
    users.insert({
        'username': sys.argv[1],
        'salt': salt,
        'pswd': encrypted_pswd,
        'algorithm': algorithm
    })