I tried to find good hashing function that will be fast and short
There is discussion Hash function that produces short hashes?
They recommend to use:
>>> import hashlib
>>> hash = hashlib.sha1("my message".encode("UTF-8")).hexdigest()
>>> hash
'104ab42f1193c336aa2cf08a2c946d5c6fd0fcdb'
>>> hash[:10]
'104ab42f11'
There is comparison table In this link https://www.tutorialspoint.com/difference-between-md5-and-sha1 That shows that MD5 is faster then SHA1
Questions are:
For caching objects (not security purposes) it seems that it's better using MD5 then SHA1, am I missing something?
Is there better Hashing that is Fast and Short
First of all, beware that it is easy to create MD5 collisions, so people could use this as an attack vector. So you'd have to be sure that no security issues are created by this.
MD5 can certainly be faster than SHA-1 but please do not forget that this depends on the implementation. I've seen pretty bad performing MD5 implementations, and current CPU's have SHA-1 acceleration build in (Intel SHA Extensions).
Yes, there are non-secure hashes like xxHash (such as in the
xxhashlibrary) that should significantly outperform any cryptographic hash out there. That's not surprising as they do not need full collision resistance.