开发者

A 16-digit hashing function

Is there a hash function that returns a 16-digit hex value (as MD5 returns 32-digit), or is there a library (for C++) in which I can use MD5 开发者_StackOverflowor SHA-1 which returns a 16-digit value


Since you're willing to live with the much-higher collision rate, you can just truncate the MD5 hash of the data.


is there a library (for C++) in which I can use MD5 or SHA-1 which returns a 16-digit value

Lookup the OpenSSL crypto library (free) or RSA BSAFE (paid).


If you truncate the size of a cryptographic hash function, you will break it - by which I mean you're very likely to damage the properties which make it cryptographically secure. If the cryptographic properties aren't important to you, then you don't need a cryptographic hash at all - you'd be better off with a checksum or non-cryptographic hash.

And whatever you're doing, don't use md5. If you need a cryptographic hash function, md5 isn't a good choice as algorithms exist that create collisions in a reasonable amount of time. If you don't need a cryptographic hash function, then md5 is overkill.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜