當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。