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


Python sha512_crypt.hash方法代码示例

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


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

示例1: _encode_secret

# 需要导入模块: from passlib.hash import sha512_crypt [as 别名]
# 或者: from passlib.hash.sha512_crypt import hash [as 别名]
def _encode_secret(attribute, new_value=None):
    if attribute == 'NT-Password':
        attribute_value = nthash.hash(new_value)
    elif attribute == 'LM-Password':
        attribute_value = lmhash.hash(new_value)
    elif attribute == 'MD5-Password':
        attribute_value = md5(new_value.encode('utf-8')).hexdigest()
    elif attribute == 'SMD5-Password':
        salt = urandom(4)
        hash = md5(new_value.encode('utf-8'))
        hash.update(salt)
        hash_encoded = encodestring(hash.digest() + salt)
        attribute_value = hash_encoded.decode('utf-8')[:-1]
    elif attribute == 'SHA-Password':
        attribute_value = sha1(new_value.encode('utf-8')).hexdigest()
    elif attribute == 'SSHA-Password':
        salt = urandom(4)
        hash = sha1(new_value.encode('utf-8'))
        hash.update(salt)
        hash_encoded = encodestring(hash.digest() + salt)
        attribute_value = hash_encoded.decode('utf-8')[:-1]
    elif attribute == 'Crypt-Password':
        attribute_value = sha512_crypt.hash(new_value)
    else:
        attribute_value = new_value
    return attribute_value 
开发者ID:openwisp,项目名称:django-freeradius,代码行数:28,代码来源:models.py

示例2: hash

# 需要导入模块: from passlib.hash import sha512_crypt [as 别名]
# 或者: from passlib.hash.sha512_crypt import hash [as 别名]
def hash(a):

    h = sha512_crypt.hash(a)
    
    return h 
开发者ID:lockedbyte,项目名称:cryptovenom,代码行数:7,代码来源:main.py

示例3: bf

# 需要导入模块: from passlib.hash import sha512_crypt [as 别名]
# 或者: from passlib.hash.sha512_crypt import hash [as 别名]
def bf(h, dictionary):

    f = open(dictionary, 'r')
    lines = f.readlines()
    print('\033[1;34m[*]\033[0m Starting Brute Force - hash = ' + h)
    for i in lines:
    
        h2 = sha512_crypt.hash(i[:-1])
    
        if h == h2:
    
            print('\033[1;32m[+]\033[0m Hash Cracked! - Password = ' + i)
            exit()
    print('\033[1;31m[-]\033[0m Hash could not be cracked!') 
开发者ID:lockedbyte,项目名称:cryptovenom,代码行数:16,代码来源:bruteforce.py

示例4: get_config

# 需要导入模块: from passlib.hash import sha512_crypt [as 别名]
# 或者: from passlib.hash.sha512_crypt import hash [as 别名]
def get_config(
    cluster_representation: ClusterRepresentation,
    extra_config: Dict[str, Any],
    dcos_variant: DCOSVariant,
    security_mode: Optional[str],
    license_key: Optional[Path],
) -> Dict[str, Any]:
    """
    Get a DC/OS configuration to use for the given cluster.
    """
    is_enterprise = bool(dcos_variant == DCOSVariant.ENTERPRISE)

    if is_enterprise:
        superuser_username = DEFAULT_SUPERUSER_USERNAME
        superuser_password = DEFAULT_SUPERUSER_PASSWORD

        enterprise_extra_config = {
            'superuser_username': superuser_username,
            'superuser_password_hash': sha512_crypt.hash(superuser_password),
            'fault_domain_enabled': False,
        }
        if license_key is not None:
            key_contents = license_key.read_text()
            enterprise_extra_config['license_key_contents'] = key_contents

        extra_config = {**enterprise_extra_config, **extra_config}
        if security_mode is not None:
            extra_config['security'] = security_mode

    dcos_config = {
        **cluster_representation.base_config,
        **extra_config,
    }

    return dcos_config 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:37,代码来源:create.py

示例5: test_enterprise

# 需要导入模块: from passlib.hash import sha512_crypt [as 别名]
# 或者: from passlib.hash.sha512_crypt import hash [as 别名]
def test_enterprise(
        self,
        cluster_backend: ClusterBackend,
        enterprise_1_9_installer: Path,
    ) -> None:
        """
        A DC/OS Enterprise 1.9 cluster can be started.
        """
        superuser_username = str(uuid.uuid4())
        superuser_password = str(uuid.uuid4())
        config = {
            'superuser_username': superuser_username,
            'superuser_password_hash': sha512_crypt.hash(superuser_password),
        }

        with Cluster(cluster_backend=cluster_backend) as cluster:
            cluster.install_dcos_from_path(
                dcos_installer=enterprise_1_9_installer,
                dcos_config={
                    **cluster.base_config,
                    **config,
                },
                output=Output.LOG_AND_CAPTURE,
                ip_detect_path=cluster_backend.ip_detect_path,
            )
            cluster.wait_for_dcos_ee(
                superuser_username=superuser_username,
                superuser_password=superuser_password,
            )
            for node in {
                *cluster.masters,
                *cluster.agents,
                *cluster.public_agents,
            }:
                build = node.dcos_build_info()
                assert build.version.startswith('1.9')
                assert build.commit
                assert build.variant == DCOSVariant.ENTERPRISE 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:40,代码来源:test_legacy.py

示例6: calico_ipip_cluster

# 需要导入模块: from passlib.hash import sha512_crypt [as 别名]
# 或者: from passlib.hash.sha512_crypt import hash [as 别名]
def calico_ipip_cluster(docker_backend: Docker, artifact_path: Path,
                        request: SubRequest, log_dir: Path) -> Iterator[Cluster]:
    with Cluster(
            cluster_backend=docker_backend,
            masters=1,
            agents=2,
            public_agents=1,
    ) as cluster:

        config = {
            "superuser_username": superuser_username,
            # We can hash the password with any `passlib`-based method here.
            # We choose `sha512_crypt` arbitrarily.
            "superuser_password_hash": sha512_crypt.hash(superuser_password),
            "calico_vxlan_enabled": "false",
            "calico_network_cidr": "192.168.128.0/17",
        }
        cluster.install_dcos_from_path(
            dcos_installer=artifact_path,
            dcos_config={
                **cluster.base_config,
                **config,
            },
            output=Output.LOG_AND_CAPTURE,
            ip_detect_path=docker_backend.ip_detect_path,
        )
        wait_for_dcos_oss(
            cluster=cluster,
            request=request,
            log_dir=log_dir,
        )
        yield cluster 
开发者ID:dcos,项目名称:dcos,代码行数:34,代码来源:test_calico_networking.py

示例7: _enterprise_distribution_test

# 需要导入模块: from passlib.hash import sha512_crypt [as 别名]
# 或者: from passlib.hash.sha512_crypt import hash [as 别名]
def _enterprise_distribution_test(
    distribution: Distribution,
    enterprise_installer: Path,
    license_key_contents: str,
) -> None:
    """
    Assert that given a ``linux_distribution``, a DC/OS Enterprise ``Cluster``
    with the Linux distribution is started.

    We use this rather than pytest parameterization so that we can separate
    the tests in ``.travis.yml``.
    """
    superuser_username = str(uuid.uuid4())
    superuser_password = str(uuid.uuid4())
    config = {
        'superuser_username': superuser_username,
        'superuser_password_hash': sha512_crypt.hash(superuser_password),
        'fault_domain_enabled': False,
        'license_key_contents': license_key_contents,
    }

    cluster_backend = Docker(linux_distribution=distribution)
    with Cluster(
        cluster_backend=cluster_backend,
        masters=1,
        agents=0,
        public_agents=0,
    ) as cluster:
        cluster.install_dcos_from_path(
            dcos_installer=enterprise_installer,
            dcos_config={
                **cluster.base_config,
                **config,
            },
            ip_detect_path=cluster_backend.ip_detect_path,
            output=Output.CAPTURE,
        )
        cluster.wait_for_dcos_ee(
            superuser_username=superuser_username,
            superuser_password=superuser_password,
        )
        (master, ) = cluster.masters
        node_distribution = _get_node_distribution(node=master)

    assert node_distribution == distribution 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:47,代码来源:test_distributions.py

示例8: test_run_enterprise_integration_test

# 需要导入模块: from passlib.hash import sha512_crypt [as 别名]
# 或者: from passlib.hash.sha512_crypt import hash [as 别名]
def test_run_enterprise_integration_test(
        self,
        ee_installer_url: str,
        license_key_contents: str,
        linux_distribution: Distribution,
    ) -> None:
        """
        It is possible to run DC/OS integration tests on AWS.
        This test module only requires a single master node.
        """
        superuser_username = str(uuid.uuid4())
        superuser_password = str(uuid.uuid4())
        config = {
            'superuser_username': superuser_username,
            'superuser_password_hash': sha512_crypt.hash(superuser_password),
            'fault_domain_enabled': False,
            'license_key_contents': license_key_contents,
            'security': 'strict',
        }

        cluster_backend = AWS(linux_distribution=linux_distribution)

        with Cluster(
            cluster_backend=cluster_backend,
            masters=1,
        ) as cluster:

            cluster.install_dcos_from_url(
                dcos_installer=ee_installer_url,
                dcos_config={
                    **cluster.base_config,
                    **config,
                },
                output=Output.LOG_AND_CAPTURE,
                ip_detect_path=cluster_backend.ip_detect_path,
            )

            cluster.wait_for_dcos_ee(
                superuser_username=superuser_username,
                superuser_password=superuser_password,
            )

            # No error is raised with a successful command.
            # We choose a test file which runs very quickly.
            fast_test_file = 'test_marathon_authn_authz.py'
            cluster.run_with_test_environment(
                args=['pytest', '-vvv', '-s', '-x', fast_test_file],
                env={
                    'DCOS_LOGIN_UNAME': superuser_username,
                    'DCOS_LOGIN_PW': superuser_password,
                },
                output=Output.LOG_AND_CAPTURE,
            ) 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:55,代码来源:test_aws.py

示例9: _enterprise_distribution_test

# 需要导入模块: from passlib.hash import sha512_crypt [as 别名]
# 或者: from passlib.hash.sha512_crypt import hash [as 别名]
def _enterprise_distribution_test(
    distribution: Distribution,
    ee_installer_url: str,
    license_key_contents: str,
) -> None:
    """
    Assert that given a ``linux_distribution``, a DC/OS Enterprise ``Cluster``
    with the Linux distribution is started.

    We use this rather than pytest parameterization so that we can separate
    the tests in ``.travis.yml``.
    """
    superuser_username = str(uuid.uuid4())
    superuser_password = str(uuid.uuid4())
    config = {
        'superuser_username': superuser_username,
        'superuser_password_hash': sha512_crypt.hash(superuser_password),
        'fault_domain_enabled': False,
        'license_key_contents': license_key_contents,
    }

    cluster_backend = AWS(linux_distribution=distribution)
    with Cluster(
        cluster_backend=cluster_backend,
        masters=1,
        agents=0,
        public_agents=0,
    ) as cluster:
        cluster.install_dcos_from_url(
            dcos_installer=ee_installer_url,
            dcos_config={
                **cluster.base_config,
                **config,
            },
            ip_detect_path=cluster_backend.ip_detect_path,
            output=Output.CAPTURE,
        )
        cluster.wait_for_dcos_ee(
            superuser_username=superuser_username,
            superuser_password=superuser_password,
        )
        (master, ) = cluster.masters
        node_distribution = _get_node_distribution(node=master)

    assert node_distribution == distribution 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:47,代码来源:test_distributions.py

示例10: test_run_pytest

# 需要导入模块: from passlib.hash import sha512_crypt [as 别名]
# 或者: from passlib.hash.sha512_crypt import hash [as 别名]
def test_run_pytest(
        self,
        cluster_backend: ClusterBackend,
        enterprise_installer: Path,
        license_key_contents: str,
    ) -> None:
        """
        Integration tests can be run with `pytest`.
        Errors are raised from `pytest`.
        """
        superuser_username = str(uuid.uuid4())
        superuser_password = str(uuid.uuid4())
        config = {
            'superuser_username': superuser_username,
            'superuser_password_hash': sha512_crypt.hash(superuser_password),
            'fault_domain_enabled': False,
            'license_key_contents': license_key_contents,
        }

        with Cluster(cluster_backend=cluster_backend) as cluster:
            cluster.install_dcos_from_path(
                dcos_installer=enterprise_installer,
                dcos_config={
                    **cluster.base_config,
                    **config,
                },
                ip_detect_path=cluster_backend.ip_detect_path,
                output=Output.LOG_AND_CAPTURE,
            )
            cluster.wait_for_dcos_ee(
                superuser_username=superuser_username,
                superuser_password=superuser_password,
            )

            # No error is raised with a successful command.
            # We choose a test file which runs very quickly.
            fast_test_file = 'test_marathon_authn_authz.py'
            cluster.run_with_test_environment(
                args=['pytest', '-vvv', '-s', '-x', fast_test_file],
                env={
                    'DCOS_LOGIN_UNAME': superuser_username,
                    'DCOS_LOGIN_PW': superuser_password,
                },
                output=Output.LOG_AND_CAPTURE,
            ) 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:47,代码来源:test_enterprise.py

示例11: test_wait_for_dcos_ee

# 需要导入模块: from passlib.hash import sha512_crypt [as 别名]
# 或者: from passlib.hash.sha512_crypt import hash [as 别名]
def test_wait_for_dcos_ee(
        self,
        cluster_backend: ClusterBackend,
        enterprise_1_11_installer: Path,
        license_key_contents: str,
    ) -> None:
        """
        A cluster can start up with SSL disabled.
        """
        superuser_username = str(uuid.uuid4())
        superuser_password = str(uuid.uuid4())
        config = {
            'superuser_username': superuser_username,
            'superuser_password_hash': sha512_crypt.hash(superuser_password),
            'fault_domain_enabled': False,
            'license_key_contents': license_key_contents,
            'security': 'disabled',
        }

        with Cluster(
            cluster_backend=cluster_backend,
            agents=0,
            public_agents=0,
        ) as cluster:
            cluster.install_dcos_from_path(
                dcos_installer=enterprise_1_11_installer,
                dcos_config={
                    **cluster.base_config,
                    **config,
                },
                output=Output.LOG_AND_CAPTURE,
                ip_detect_path=cluster_backend.ip_detect_path,
            )
            cluster.wait_for_dcos_ee(
                superuser_username=superuser_username,
                superuser_password=superuser_password,
            )

            # On 1.11 with security mode disabled, SSL is disabled.
            any_master = next(iter(cluster.masters))
            config_result = any_master.run(
                args=['cat', '/opt/mesosphere/etc/bootstrap-config.json'],
            )
            config = json.loads(config_result.stdout.decode())
            ssl_enabled = config['ssl_enabled']
            assert not ssl_enabled 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:48,代码来源:test_enterprise.py


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