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


Python sha256_crypt.encrypt方法代码示例

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


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

示例1: set_password

# 需要导入模块: from passlib.hash import sha256_crypt [as 别名]
# 或者: from passlib.hash.sha256_crypt import encrypt [as 别名]
def set_password(self, value):
        password_config = settings.load().get('password', None)
        if password_config and password_config.get('enforce'):
            regex = password_config['regex']
            rules = password_config.get('rules', [])
            if re.match(regex, value) is None:
                raise PasswordPolicyError(regex, rules)
        self.sha256_hash = sha256_crypt.encrypt(value) 
开发者ID:mitre,项目名称:cascade-server,代码行数:10,代码来源:users.py

示例2: signup

# 需要导入模块: from passlib.hash import sha256_crypt [as 别名]
# 或者: from passlib.hash.sha256_crypt import encrypt [as 别名]
def signup():
    form = SignupForm(request.form)

    if request.method == 'POST' and form.validate():
        name = form.name.data
        email = form.email.data
        username = form.username.data
        password = sha256_crypt.encrypt(str(form.password.data))

        try:
            # Create cursor
            cur = mysql.connection.cursor()

            cur.execute("INSERT INTO users(name, email, username, password) \
                VALUES(%s, %s, %s, %s)", (name, email, username, password))

            # Commit to DB
            mysql.connection.commit()

            # Close connection
            cur.close()

            flash('You are now signed up', 'success')

        except Exception as e:
            flash("{}".format(e.args[1]), category='warning')

        return(redirect(url_for('home')))

    return render_template('signup.html', form=form) 
开发者ID:devopsloft,项目名称:devopsloft,代码行数:32,代码来源:application.py

示例3: encrypt

# 需要导入模块: from passlib.hash import sha256_crypt [as 别名]
# 或者: from passlib.hash.sha256_crypt import encrypt [as 别名]
def encrypt(password):
    return sha256_crypt.encrypt(password) 
开发者ID:datacats,项目名称:ckan-multisite,代码行数:4,代码来源:pw.py

示例4: genpass

# 需要导入模块: from passlib.hash import sha256_crypt [as 别名]
# 或者: from passlib.hash.sha256_crypt import encrypt [as 别名]
def genpass():
    from passlib.hash import sha256_crypt
    pw = get_pass()
    print(sha256_crypt.encrypt(pw)) 
开发者ID:CenterForOpenScience,项目名称:cos-ansible-base,代码行数:6,代码来源:tasks.py

示例5: get_hash

# 需要导入模块: from passlib.hash import sha256_crypt [as 别名]
# 或者: from passlib.hash.sha256_crypt import encrypt [as 别名]
def get_hash(password):
    """ Returns a new SHA256 Hash for a password (lower rounds for speed)"""

    phash = sha256_crypt.encrypt(password, rounds=100000)
    return phash 
开发者ID:yantisj,项目名称:netgrph,代码行数:7,代码来源:user.py

示例6: get_phash

# 需要导入模块: from passlib.hash import sha256_crypt [as 别名]
# 或者: from passlib.hash.sha256_crypt import encrypt [as 别名]
def get_phash(passwd):
    """ Get a new hashed password """

    return sha256_crypt.encrypt(passwd, rounds=100000) 
开发者ID:yantisj,项目名称:apisrv,代码行数:6,代码来源:user.py

示例7: register

# 需要导入模块: from passlib.hash import sha256_crypt [as 别名]
# 或者: from passlib.hash.sha256_crypt import encrypt [as 别名]
def register():
    form = RegisterForm(request.form)
    if request.method == 'POST' and form.validate():
        name = form.name.data
        email = form.email.data
        username = form.username.data
        password = sha256_crypt.encrypt(str(form.password.data))

        # Create cursor
        cur = mysql.connection.cursor()

        # Execute query
        cur.execute("INSERT INTO users(name, email, username, password) VALUES(%s, %s, %s, %s)", (name, email, username, password))

        # Commit to DB
        mysql.connection.commit()

        # Close connection
        cur.close()

        flash('You are now registered and can log in', 'success')

        return redirect(url_for('login'))
    return render_template('register.html', form=form)


# User login 
开发者ID:bradtraversy,项目名称:myflaskapp,代码行数:29,代码来源:app.py


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