def hash_password(user_manager, password):
    """ Generate hashed password using SHA512 HMAC and the USER_PASSWORD_HASH hash function."""
    # Handle plaintext storage
    if user_manager.password_hash == 'plaintext':
        return password
    # Generate SHA512 HMAC -- For compatibility with Flask-Security
    if user_manager.password_hash_mode == 'Flask-Security':
        password = generate_sha512_hmac(user_manager.password_salt, password)
    # Use passlib to hash password
    hashed_password = user_manager.password_crypt_context.encrypt(password)

    return hashed_password
dataset/ETHPy150Open lingthio/Flask-User/flask_user/passwords.py/hash_password/original