Afficher un message
Vieux 25/03/2008, 23h21   #1
macm
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Why all hash algorithm are hexadecimal in PHP?

Hi Folks

I tested

<?php
echo 'sha256=>' .hash('sha256', 'The quick brown fox jumped over the
lazy dog.') .'</br>';
echo 'sha384=>' .hash('sha384', 'The quick brown fox jumped over the
lazy dog.') .'</br>';
echo 'sha512=>' .hash('sha512', 'The quick brown fox jumped over the
lazy dog.') .'</br>';
echo 'ripemd128=>' .hash('ripemd128', 'The quick brown fox jumped over
the lazy dog.') .'</br>';
echo 'ripemd160=>' .hash('ripemd160', 'The quick brown fox jumped over
the lazy dog.') .'</br>';
echo 'whirlpool=>' .hash('whirlpool', 'The quick brown fox jumped over
the lazy dog.') .'</br>';
echo 'tiger128,3=>' .hash('tiger128,3', 'The quick brown fox jumped
over the lazy dog.') .'</br>';
echo 'tiger160,3=>' .hash('tiger160,3', 'The quick brown fox jumped
over the lazy dog.') .'</br>';
echo 'tiger192,4=>' .hash('tiger192,4', 'The quick brown fox jumped
over the lazy dog.') .'</br>';
echo 'snefru=>' .hash('snefru', 'The quick brown fox jumped over the
lazy dog.') .'</br>';
echo 'gost=>' .hash('gost', 'The quick brown fox jumped over the lazy
dog.') .'</br>';
echo 'adler32=>' .hash('adler32', 'The quick brown fox jumped over the
lazy dog.') .'</br>';
echo 'crc32=>' .hash('crc32', 'The quick brown fox jumped over the
lazy dog.') .'</br>';
echo 'crc32b=>' .hash('crc32b', 'The quick brown fox jumped over the
lazy dog.') .'</br>';
echo 'haval128,3=>' .hash('haval128,3', 'The quick brown fox jumped
over the lazy dog.') .'</br>';
echo 'haval256,5=>' .hash('haval256,5', 'The quick brown fox jumped
over the lazy dog.') .'</br>';
?>

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
  Réponse avec citation
 
Page generated in 0,05384 seconds with 9 queries