I am writing a program in Python for elliptic curve cryptography (for school and out of interest). I am currently working on the digital signature algorithm. I am currently looking for a good and secure hashing function which is either standard in Python or can easily be downloaded and imported. I thought about SHA256, since that's the only one I know which hasn't been broken yet (as far as I know). However, I have also read that SHA shouldn't be used for cryptography. Is SHA256 appropriate for a digital signature algorithm? Or should a different hashing function be used? If so, which one would be a good choice?
A cryptographic hash function is an algorithm that takes an arbitrary amount of data input—a credential—and produces a fixed-size output of enciphered text called a hash value, or just “hash.” That enciphered text can then be stored instead of the password itself, and later used to verify the user.
Python hash() function is a built-in function and returns the hash value of an object if it has one. The hash value is an integer which is used to quickly compare dictionary keys while looking at a dictionary.
A “cryptographic” hash function is one that makes finding hash collisions very difficult, and thus prevents attackers from landing collision attacks. So, there you have it: Python uses SipHash because it's a trusted, cryptographic hash function that should prevent collision attacks.
I use SHA-512 for a similar purpose, I think you'd be hard pressed to get much more secure than that. SHA-512 is available in python's hashlib, and can be used like so:
import hashlib
hashGen = hashlib.sha512()
hashGen.update("What you want to hash")
hash = hashGen.hexdigest()
print "your hash is: ", hash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With