Solved

avoiding collisions with SHA1

Posted on 2006-07-05
4
410 Views
Last Modified: 2010-04-11
I wasn't sure which section I should ask this question in, because it isn't a true security question, but it is a question about using the SHA1 algorithm, so I figured that I'd have the best luck in the security section.

I'm using SHA1 as a hash function in my application,  I was wondering if anybody knew what factors to use (or not to use) when giving data to the function to compute the hash for avoiding collisions.   For example is there a range of optimal input lengths that reduce collisions?  Is it bad to use a limited range of input values (ie. only ascii chars).  If anybody has any insight on this it would be very useful.

Thanks,
Nick
0
Comment
Question by:spikey_nick
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
chandrasuresh earned 250 total points
Comment Utility
SHA1, as far as ascii data is considered is very secure and collision free. You can safely use SHA1 in any of your normal applications.
As you would have known, no two strings will produce the same or nearly same hashes even if they both differ by a bit.
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
It _is_ possible to have two different plaintexts produce the same hash with SHA or with any other hash but the probability is extremely low.  The best ways to ensure that you don't get a collision is to:

1) Use a strong key.  SHA1 has some weak keys for seeding the hash.  Avoid any of these.
2) Use a long enough hash size.  Obviously, shorter hashes, while faster to generate, are more likely to produce a collision.
0
 
LVL 2

Expert Comment

by:chandrasuresh
Comment Utility
SHA1 does not use any key. It just produces  a message digest of the input data given. Also, SHA1 produces a fixed length hash of 20 bytes, whatever is the input length.

jhance, Can you please detail about the key and the hash length which you have specified?
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
chandra,

Yes, you are correct.  I was thinking HMAC-SHA1 but this question is about SHA-1.

Regardless, the probability of a collision with 20 bytes of hash is quite low.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now