hash

Murmur3 Hash Compatibility Between Go and Python

Murmur3 Hash Compatibility Between Go and Python Question: We have two different libraries, one in Python and one in Go that need to compute murmur3 hashes identically. Unfortunately no matter how hard we try, we cannot get the libraries to produce the same result. It appears from this SO question about Java and Python that …

Total answers: 1

Python how identify if an instance has been changed without making a copy?

Python how identify if an instance has been changed without making a copy? Question: I’m trying to write a function to determine if an object has been modified at one point during the execution of the program. I don’t want to duplicate the object because this will take a lot of memory. My object is …

Total answers: 3

TypeError: Unhashable type: 'numpy.ndarray' in keras

TypeError: Unhashable type: 'numpy.ndarray' in keras Question: I have a code below while True: question = input("你: ") question_seq = tokenizer.texts_to_sequences([question]) question_seq_padded = keras.preprocessing.sequence.pad_sequences(question_seq, maxlen=max_len) answer_seq = model.predict(question_seq_padded).argmax(axis=-1)[0] answer = tokenizer.index_word[answer_seq] print("機器人:", answer) And when i ran it, happened some wrong answer = tokenizer.index_word[answer_seq] issued error TypeError: Unhashable type: ‘numpy.ndarray’ I try to find the …

Total answers: 2

How to fix this problem when generating a pseudorandom number in Python?

How to fix this problem when generating a pseudorandom number in Python? Question: import hashlib import time def random(): hashtime = str(int(time.time() * (10 ** 6))) encoded = hashlib.new("sha3_512", hashtime.encode()) decoded = int(encoded.hexdigest(), 16) dcsmall = decoded / (10 ** (len(str(decoded)))) return (dcsmall) I tried this code to simulate the function random.random() without the module …

Total answers: 2

Python compare two SHA512 hashes

Python compare two SHA512 hashes Question: I have two SHA512 hashes with salt: h1 = "412e00cc45afb8d2d5675bf5de0d1bb83eb85ab4af2c5560c8cc580feeb319565cde4e8d57ff847c0c6d9c6681d68d7850da594932d66fd65db133b19e5b31ec:9c0d2ff09e8c43babc49d42ad215e0fa" h2 = "bc80293178d0aa302f5372a744a2acd3d4f7350b635bcdbded1f95fba187a4d04b429b30fb94daed2a94be3ec2c9ed5a110827f3a794b9f8c40fcdd41015e2c2:1a8de82d82134aecbab7f6d0c37c8444" Is it possible to compare them, to derive if they are generated from the same password without having the password? hashlib.sha512(h1.encode).digest() == hashlib.sha512(h2.encode).digest() Asked By: cheat.008 || Source Answers: No. You’ve got both hash and salt …

Total answers: 1

What's the chance of a collision in Python's secrets. compare_digest function?

What's the chance of a collision in Python's secrets. compare_digest function? Question: The closest function I can find to a constant time compare in Python’s standard library is secrets.compare_digest But it makes me wonder, if in the case of using it to verify a secret token: What’s the chance of a collision? As in, what’s …

Total answers: 1

Hash a column in CSV and output in Base64

Hash a column in CSV and output in Base64 Question: Still getting my feet wet with Python, but my goal is to read a CSV file and hash a specific column using SHA256 then output in Base64. Here is an example of the conversion that needs to take place This calculator can be found at …

Total answers: 2

pickle and dill can't load objects with overridden __hash__ function (AttributeError)

pickle and dill can't load objects with overridden __hash__ function (AttributeError) Question: In the next few lines of code I’ll replicate on a smaller scale what’s happening with my program. Class A must store a dictionary with keys that have type A (values can be any type to replicate the error). class A: def __init__(self, …

Total answers: 1

How to override the hash function for integers in python?

How to override the hash function for integers in python? Question: I’d like to know if there is a way to override the hash function that are already defined for builtin types like int. In python the hash of an int gives his own value and i’d like to avoid that in my project. The …

Total answers: 1