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


Python hashlib.sha3_512方法代码示例

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


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

示例1: handle_disconnect_room

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import sha3_512 [as 别名]
def handle_disconnect_room(p):
    if p.room.blackhole:
        await p.room.leave_blackhole(p)
    await p.room.remove_penguin(p)

    minutes_played = (datetime.now() - p.login_timestamp).total_seconds() / 60.0

    ip = p.peer_name[0] + p.server.config.auth_key
    hashed_ip = hashlib.sha3_512(ip.encode()).hexdigest()
    await Login.create(penguin_id=p.id,
                       date=p.login_timestamp,
                       ip_hash=hashed_ip,
                       minutes_played=minutes_played)

    await p.update(minutes_played=p.minutes_played + minutes_played).apply()

    del p.server.penguins_by_id[p.id]
    del p.server.penguins_by_username[p.username]

    server_key = f'houdini.players.{p.server.config.id}'
    await p.server.redis.srem(server_key, p.id)
    await p.server.redis.hincrby('houdini.population', p.server.config.id, -1) 
开发者ID:solero,项目名称:houdini,代码行数:24,代码来源:navigation.py

示例2: renderfile

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import sha3_512 [as 别名]
def renderfile(self, filename):
        """
            Render a markdown and returns the blogEntry.
            Note: This method uses a cache based on a SHA-256 hash of the
            content.
        :param filename: Number of the file without extension.
        :return: BlogEntry.
        :raises PageNotExistError Raise this error if file does not exists.
        """
        filepath = path.join(self.postdir, filename + ".md")
        if not path.exists(filepath):
            raise PageNotExistError(f"{filename} does not exists in {self.postdir} directory")
        with open(filepath, "r", encoding="utf-8") as content_file:
            content = content_file.read()
            # Check cache
            content_hash = sha3_512(content.encode())
            if content_hash not in self.cache:
                entry = self.rendertext(filename, content)
                self.cache[content_hash] = entry

        return self.cache[content_hash] 
开发者ID:zerasul,项目名称:blask,代码行数:23,代码来源:blogrenderer.py

示例3: H

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import sha3_512 [as 别名]
def H(m):
    return hashlib.sha3_512(m).digest() 
开发者ID:hyperledger,项目名称:iroha-python,代码行数:4,代码来源:ed25519.py

示例4: test_p224_sha3_512

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import sha3_512 [as 别名]
def test_p224_sha3_512(self):
        url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp224r1_sha3_512_test.json"
        tests = self._get_tests(url)
        self._test_runner(tests, P224, sha3_512) 
开发者ID:AntonKueltz,项目名称:fastecdsa,代码行数:6,代码来源:test_whycheproof_vectors.py

示例5: test_secp256k1_sha3_512

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import sha3_512 [as 别名]
def test_secp256k1_sha3_512(self):
        url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp256k1_sha3_512_test.json"
        tests = self._get_tests(url)
        self._test_runner(tests, secp256k1, sha3_512) 
开发者ID:AntonKueltz,项目名称:fastecdsa,代码行数:6,代码来源:test_whycheproof_vectors.py

示例6: test_p256_sha3_512

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import sha3_512 [as 别名]
def test_p256_sha3_512(self):
        url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp256r1_sha3_512_test.json"
        tests = self._get_tests(url)
        self._test_runner(tests, P256, sha3_512) 
开发者ID:AntonKueltz,项目名称:fastecdsa,代码行数:6,代码来源:test_whycheproof_vectors.py

示例7: test_p384_sha3_512

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import sha3_512 [as 别名]
def test_p384_sha3_512(self):
        url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp384r1_sha3_512_test.json"
        tests = self._get_tests(url)
        self._test_runner(tests, P384, sha3_512) 
开发者ID:AntonKueltz,项目名称:fastecdsa,代码行数:6,代码来源:test_whycheproof_vectors.py

示例8: test_p521_sha3_512

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import sha3_512 [as 别名]
def test_p521_sha3_512(self):
        url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp521r1_sha3_512_test.json"
        tests = self._get_tests(url)
        self._test_runner(tests, P521, sha3_512) 
开发者ID:AntonKueltz,项目名称:fastecdsa,代码行数:6,代码来源:test_whycheproof_vectors.py

示例9: sha3_512

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import sha3_512 [as 别名]
def sha3_512(self):
        """Get SHA3-512 hash
        
        The SHA-3 (Secure Hash Algorithm 3) hash functions were released by NIST on August 5, 2015. 
        Although part of the same series of standards, SHA-3 is internally quite different from the 
        MD5-like structure of SHA-1 and SHA-2.<br><br>SHA-3 is a subset of the broader cryptographic 
        primitive family Keccak designed by Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche, 
        building upon RadioGatún.

        Returns:
            Chepy: The Chepy object. 
        """
        self.state = hashlib.sha3_512(self._convert_to_bytes()).hexdigest()
        return self 
开发者ID:securisec,项目名称:chepy,代码行数:16,代码来源:hashing.py

示例10: test_salt

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import sha3_512 [as 别名]
def test_salt(self):
        data = b'sdfKK32411112sdfd'
        m = hashlib.sha3_512(b'>>>kK3.2')
        m.update(data)
        md5 = m.hexdigest()
        self.assertEqual(get_hash(data, salt='>>>kK3.2', hash_name='sha3_512'), md5)
        self.assertEqual(get_hash(data, salt=b'>>>kK3.2', hash_name='sha3_512'), md5) 
开发者ID:fufuok,项目名称:FF.PyAdmin,代码行数:9,代码来源:test_get_hash.py

示例11: calculate_cache_key

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import sha3_512 [as 别名]
def calculate_cache_key(machine: Machine) -> str:
        """
                Calculates a hash-key from the model and data-config.

                Returns
                -------
                str:
                    A 512 byte hex value as a string based on the content of the parameters.

                Examples
                -------
                >>> from gordo.machine import Machine
                >>> from gordo.machine.dataset.sensor_tag import SensorTag
                >>> machine = Machine(
                ...     name="special-model-name",
                ...     model={"sklearn.decomposition.PCA": {"svd_solver": "auto"}},
                ...     dataset={
                ...         "type": "RandomDataset",
                ...         "train_start_date": "2017-12-25 06:00:00Z",
                ...         "train_end_date": "2017-12-30 06:00:00Z",
                ...         "tag_list": [SensorTag("Tag 1", None), SensorTag("Tag 2", None)],
                ...         "target_tag_list": [SensorTag("Tag 3", None), SensorTag("Tag 4", None)]
                ...     },
                ...     project_name='test-proj'
                ... )
                >>> builder = ModelBuilder(machine)
                >>> len(builder.cache_key)
                128
                """
        # Sets a lot of the parameters to json.dumps explicitly to ensure that we get
        # consistent hash-values even if json.dumps changes their default values
        # (and as such might generate different json which again gives different hash)
        json_rep = json.dumps(
            {
                "name": machine.name,
                "model_config": machine.model,
                "data_config": machine.dataset.to_dict(),
                "evaluation_config": machine.evaluation,
                "gordo-major-version": MAJOR_VERSION,
                "gordo-minor-version": MINOR_VERSION,
            },
            sort_keys=True,
            default=str,
            skipkeys=False,
            ensure_ascii=True,
            check_circular=True,
            allow_nan=True,
            cls=None,
            indent=None,
            separators=None,
        )
        logger.debug(f"Calculating model hash key for model: {json_rep}")
        return hashlib.sha3_512(json_rep.encode("ascii")).hexdigest() 
开发者ID:equinor,项目名称:gordo,代码行数:55,代码来源:build_model.py


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