Python hashlib.sha3_512() Examples
The following are 11
code examples of hashlib.sha3_512().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
hashlib
, or try the search function
.
Example #1
Source File: navigation.py From houdini with MIT License | 6 votes |
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)
Example #2
Source File: blogrenderer.py From blask with GNU General Public License v3.0 | 6 votes |
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]
Example #3
Source File: ed25519.py From iroha-python with Apache License 2.0 | 5 votes |
def H(m): return hashlib.sha3_512(m).digest()
Example #4
Source File: test_whycheproof_vectors.py From fastecdsa with The Unlicense | 5 votes |
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)
Example #5
Source File: test_whycheproof_vectors.py From fastecdsa with The Unlicense | 5 votes |
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)
Example #6
Source File: test_whycheproof_vectors.py From fastecdsa with The Unlicense | 5 votes |
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)
Example #7
Source File: test_whycheproof_vectors.py From fastecdsa with The Unlicense | 5 votes |
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)
Example #8
Source File: test_whycheproof_vectors.py From fastecdsa with The Unlicense | 5 votes |
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)
Example #9
Source File: hashing.py From chepy with GNU General Public License v3.0 | 5 votes |
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
Example #10
Source File: test_get_hash.py From FF.PyAdmin with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #11
Source File: build_model.py From gordo with GNU Affero General Public License v3.0 | 4 votes |
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()