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