PHP hash function with long output length?

Inside my code, I generate hashes of URLs (which are of almost unlimited length). I am currently using sha1 (), which I know has a tiny chance of collision, but I have up to 255 bytes to store the hash, so I can use this available space to reduce the likelihood of a collision even later on.

Whether there is a:

  • Another PHP hash function with a longer or custom hash length?
  • How to use a fixed length hash function like sha1 with an input variable length to generate a longer hash?

Or is sha1 a 20-byte hash good enough for anything, and should I stop worrying about it?

+3
source share
7 answers

, 20- sha1, -, ?

.

Hashtables, Pigeonholes
http://www.codinghorror.com/blog/archives/001014.html

+5

... http://www.cryptography.com/cnews/hash.html

: SHA-1?
A: 2 ^ 69 ( 590 . .) -

, ... ^ _ ^

+3

, 256- 512- (32 64 ).

, , .

, , md5 sha-256.

+1

/ ( ) ?

, , , a) b) ( - , , / ).

, -, ?

0

, , , , . :

found = false
hv = hash(urlValue)
if table[hash,url] contains pair (hv,urlValue)
   found = true
endif

if (not found)
   insert table (hv,urlValue)
endif

hash, . (, url) - , , , , URL-. -. , URL- , .

0

, , URL.

, URL- 40 - 5 : SHA1 1-8, SHA1 9-16, SHA1 17-24... .. 2 800 2 (69 * 5)= 2 345= 7.2 * 10 103 .

, , .

0

, , - . .

0

Source: https://habr.com/ru/post/1699660/


All Articles