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