views:

115

answers:

3

Hi, I want to create a unique hash (16 chars long) of an arbitrary length String. Is there a good library that implements MD5 or SHA-1 for C++ with which I can achieve this? (and possibly an example of how to use it)

+4  A: 

The Pigeonhole Principle explains why what you ask is impossible regarding uniqueness.

Ben S
how does MD5 work, because it hashes arbitrary length strings to 32-digit hex values
Aly
Yes, but if you run enough strings through MD5 you'll end up with two different strings which have the same hash: http://www.google.com/search?q=md5+collision
Ben S
+1  A: 

You need the openssl library. It has implementations of the standard crypto hashes for this purpose.

bmargulies
+1  A: 

nss provides a number of hash and cryptographic algorithms and has a more liberal license than OpenSSL.

Ignacio Vazquez-Abrams