Afficher un message
Vieux 26/03/2008, 01h14   #4
Jeremy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Why all hash algorithm are hexadecimal in PHP?

macm wrote:
> As you can see all results are hexadecimal.
>
> Youtube for example have http://youtube.com/watch?v=n5pkDB7zEeo
>
> n5pkDB7zEeo inst hexadecimal so the comparison is simple.
>
> md5 algorithm have 32^16 = 1,2e^24
>
> youtube algorithm have 11^63 = 405e^63 (because is case sensitive so
> combination is [0-9]+[a-Z] + "_" ) (Could have more caracteres!)
>
> So with only 11 caracteres I can have much more combination and much
> less collision.
>
> So how can I create a hash algorithm like youtube? with 11 caracteres
> [0-9]+[a-Z] + "_"
>
> Some tips? How compile?
>
> Cheers
>
> Mario


Your math is backwards. Youtube's scheme has 63^11 (not 11^63)
combinations, which is about 6.2e19 possibilities.

If you want shorter, url-safe identifiers, you could do something
similar with base64. For example, if you bump the identifier up to 12
characters (multiples of 4 are good for base64) you would get 9 bytes of
data = (2^8)^9 = 2^72 ~= 4.7e21 combinations. Just replace the '/' and
'+' characters from base64 with different, url-safe characters (because
'/' and '+' have meaning in a URI).

Jeremy
  Réponse avec citation
 
Page generated in 0,05357 seconds with 9 queries