Improved safety of hash function