What module do you have to import for using hashing?
import hashlib
How can you create a hashing function?
hash_function = hashlib.sha256()
In what way should you encode the data when we want to use hashing?
You have to encode the data in byte-like form
some_data = bytes(some_data, encoding="utf-8")
some_data.encode("utf-8")
some_data = b"A string"
Which methods are imported when using hashing and what do they do?
update() is used for feeding the data to hash
digest() is used for computing the hash value
hash_function.update(some_data)
first_hash = hash_function.digest()
If you use the same input for hashing, which hash values should you get?
The same hash values
If you use different input for hashing, which hash values should you get?
Different hash values
If you use the same input for hashing but different salt parameters, which hash values should you get?
Different ones
How does the built-in hash function work and what is special about it?
python_hash = hash(some_array_bytes)
You get different hash values in different python sessions, since the built-in hash function applies random salt
What are advantages of hashing?
Hashing works on any input
Hash values stay the same throughout different sessions
The computation of hash values is very quick
Zuletzt geändertvor 2 Jahren