Is there an issue with putting a longer input string to a hashing algorithm than the algorithm outputs?

StackOverflow https://stackoverflow.com/questions/16661249

문제

Currently I'm designing a hashing system for user emails, but what happens if the user email is longer than the hash output. I usually use sha1 sha256 or sha512 if it makes a difference based on algorithm... It just seems like at a point the algorithm wouldn't be able to keep on producing unique outputs.

도움이 되었습니까?

해결책

Hash values usually have a fixed length from 13 (DES) to 86 (SHA2) characters. It's perfectly normal if you give longer input. Think of it like a "cross sum" that you can do with arbitrary long numbers as well.

Regarding the uniqueness, using the standard crypt(3) function with SHA-512 and characters in the set a-zA-Z./ you have 54 different characters and a 86 character long string so 54^86 different values. That's a lot :-)

(Don't use the 13 char long DES crypt though, that's bruteforceable with modern hardware and always use "salt" values so that the same input string gives different hash values and you can't use a "rainbow table" attack).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top