473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
Mar 25 '08 #1
4 3443
More compact than using decimal and easier to type and/or read (if
needed) than broader full alpha numeric formats.
Mar 25 '08 #2
macm wrote:
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
What do y0ou need more than that for? The chances of a collision with
md5 and the rest are VERY remote.

You're much more likely to have a duplicate in the 11 characters than
you will in any of the hashes.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Mar 25 '08 #3
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
Mar 25 '08 #4
NC
On Mar 25, 2:21 pm, macm <moura.ma...@gmail.comwrote:
>
how can I create a hash algorithm like youtube?
Why do you think it's a hash? It's probably a unique ID represented
as a 62-based number...
Some tips? How compile?
If you are content with case-insensitive IDs (meaning 36-based
numbers) you can use base_convert():

http://php.net/base_convert

If you insist on higher base, you would have to write the conversion
routine yourself...

Cheers,
NC
Mar 26 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Weiguang Shi | last post by:
Hi there, I'm thinking of using binascii.crc32 as a hash-function when I read in the reference http://www.python.org/doc/current/lib/module-binascii.html: crc32( data) Compute CRC-32, the...
34
by: pembed2003 | last post by:
Hi All, Does C++/STL have hashtable where I can do stuff like: Hashtable h<int>; h.store("one",1); h.store("two",2); and then later retrieve them like:
4
by: flipdog | last post by:
Hello all, I didn't know there is a thread on hash function started in this newsgroup so reposted my posting from another group. Hope I can have some feedbacks. I am new to hash table. I came...
5
by: HamuNaptra | last post by:
Hi im trying to get a hash from a string and conert it back to a string eg. "test" = "098f6bcd4621d373cade4e832627b4f6" my function: Private Function GenerateHash(ByVal SourceText As...
1
by: Fernando Barsoba | last post by:
Hi all, First of all, I'd like to thank you "Skarmander" and "Flash Gordon" for the help they provided me: Skarmander's algorithm and Flash's modifications helped me a lot. Here's the problem...
5
by: lavu | last post by:
I am trying to provide some security to text files, by adding a signature at the end of each text file. this signature needs to be generated by some kind of hashing algorithm. so while sending...
1
by: Wayne Deleersnyder | last post by:
Hi All, I was going to write and ask if someone could help me fix the formatting of my output for hash values, but I believe I got it right now. But, because I couldn't find any website or...
16
by: Robin Becker | last post by:
Is the any way to get an efficient 16bit hash in python? -- Robin Becker
6
by: j1mb0jay | last post by:
I am currently working on a dictionary populating program. I currently have a socket connection my local news server and am trawling through all of the articles looking for new words. I am...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.