Reputation: 1
Split the message into 160-bit blocks. Leave the first block unchanged, shift the 2nd block 1 bit left, shift the 3rd block 2 bits left, and so on. The shift wraps bits around, i.e., 1011...00 shifted 2 bits left is 11...0010. Then xor the resulting blocks together to obtain a 160-bit digest.
Is this a good hash function?
Upvotes: 0
Views: 347
Reputation:
If you are interested in alternates of SHA-1 then look in to SHA-2 and SHA-3
As of now SHA-2 is most secure hashing algorithm. And about SHA-3 Wikipedia says:
SHA-3 is not meant to replace SHA-2, as no significant attack on SHA-2 has been demonstrated
Upvotes: 0
Reputation: 10989
Do you need cryptographic strength hash function? Are you planning to use it to:
If so, use an existing and tested hash function. SHA-1 itself is regarded as vulnerable an unsuitable for secure applications and it's way more secure than your algorithm. Almost everyone (myself included) is dangerously bad at cryptography. If you haven't even tested your hash function, or don't know how to test a hash function, you aren't that good at crypto either.
Or can you get away with a normal hash function? Are you just using this for internal computations that don't get saved or stored? Then you might have a need to roll your own hash function. From your default to 160-bit digests and comparison to SHA-1, it doesn't sound like this is your use case. Most non-crypto hash functions roll out power-of-two digest lengths. Again, however, there are other open sourced and tested hash functions available, so why re-invent the wheel?
If you want to learn, I suggest you implement your hash function in code then put in the effort to test it. See this question for some primer info on this. There is an open source project called SMHasher that "is a test suite designed to test the distribution, collision, and performance properties of non-cryptographic hash functions - it aims to be the "DieHarder" of hash testing, and does a pretty good job of finding flaws with a number of popular hashes."
Upvotes: 1