News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
How to Create a Unique 64bit Integer from String
August 14, 2014 @ 12:55:33

In the latest post to the SitePoint PHP blog Vova Feldman shows you how to create an integer from a hash string that's both 64 bit and unique each time it's generated.

PHP provides the popular md5() hash function out of the box, which returns 32 a hex character string. It's a great way to generate a fingerprint for any arbitrary length string. But what if you need to generate an integer fingerprint out of a URL?

He describes the real-world situation he was facing - a rating widget that needed a randomized integer based on the page using it - and the two "sub-challenges" that make it up: url canonization and the string to unique 64 bit problem. He tackles each problem and shares code snippets showing the process and how it can be put to use. He also includes some interesting metrics at the end of the post showing the level of hash collisions (hint, it's a very low number).

0 comments voice your opinion now!
unique integer string 64bit tutorial md5 hash

Link: http://www.sitepoint.com/create-unique-64bit-integer-string/

blog comments powered by Disqus

Similar Posts

PHPHacks.com: How to create an Ajax RSS reader with PHP

Stefan Mischook's Blog: Creating Your Own Functions - Part 2

Phish Tank: Install & Configure Apache+PHP+ZendFramework+OracleDbXe On Windows In Minutes

Anthony Wlodarski's Blog: Node.js and Zend Auth with Sessions stored in the database

PHPBuilder.com: PHP and Regular Expressions 101


Community Events





Don't see your event here?
Let us know!


deployment voicesoftheelephpant interview community symfony language api threedevsandamaybe laravel zendserver conference introduction code series podcast release tips framework list bugfix

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework