当前位置: 首页>>代码示例>>Python>>正文


Python Util.hash方法代码示例

本文整理汇总了Python中util.Util.hash方法的典型用法代码示例。如果您正苦于以下问题:Python Util.hash方法的具体用法?Python Util.hash怎么用?Python Util.hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在util.Util的用法示例。


在下文中一共展示了Util.hash方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: is_user_authenticated

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import hash [as 别名]
 def is_user_authenticated(self, username, password):
   """
   This method returns True if the given password matches the password
   stored in the database for the given user. This method takes a plaintext
   username and password to check as arguments.
   """
   user = self.get_user_by_username(username)
   if user:
     return user['password'] == Util.hash(password)
   return False
开发者ID:omgimanerd,项目名称:softdev,代码行数:12,代码来源:database_manager.py

示例2: is_user_authorized

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import hash [as 别名]
 def is_user_authorized(self, username, password):
   connection = sqlite3.connect(self.database)
   c = connection.cursor()
   # We can assume username is a unique field.
   c.execute('SELECT password FROM users WHERE username=?',
             (username,))
   actual_password = c.fetchone()
   connection.close()
   if actual_password:
     return actual_password[0] == Util.hash(password)
   return False
开发者ID:omgimanerd,项目名称:softdev,代码行数:13,代码来源:database_manager.py

示例3: register_user

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import hash [as 别名]
 def register_user(self, username, password, fullname):
   connection = sqlite3.connect(self.database);
   c = connection.cursor()
   result = True
   try:
     c.execute('INSERT INTO users VALUES (?, ?, ?)',
               (username, Util.hash(password), fullname))
   except sqlite3.IntegrityError:
     result = False
   connection.commit()
   connection.close()
   return result
开发者ID:omgimanerd,项目名称:softdev,代码行数:14,代码来源:database_manager.py

示例4: set_user_password

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import hash [as 别名]
 def set_user_password(self, username, password):
   """
   This method changes the password of a user given the username and the new
   password of the user to change. Returns True if the change was successful
   and False otherwise.
   """
   try:
     self.db['users'].update({
       'username': username
     }, {
       '$set': {
         'password': Util.hash(password)
       }
     })
     return True
   except:
     return False
开发者ID:omgimanerd,项目名称:softdev,代码行数:19,代码来源:database_manager.py

示例5: register_user

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import hash [as 别名]
 def register_user(self, username, password, zipcode, phone):
   """
   Registers a user into the database and returns True upon success or
   False if the registration failed. This method will fail if the user
   exists already. This method takes the username, password, and email
   of the user to register as arguments.
   """
   try:
     self.db['users'].insert_one({
       'username': username,
       'password': Util.hash(password),
       'zipcode': zipcode,
       'phone': phone,
       'metric': False
     })
     return True
   except:
     return False
开发者ID:omgimanerd,项目名称:softdev,代码行数:20,代码来源:database_manager.py


注:本文中的util.Util.hash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。