News Feed
Sections




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

Sameer Borate's Blog:
How not to create a Random string
November 26, 2010 @ 10:18:48

In this latest post to his blog, Samer Borate talks about how not to create random strings and how, if you're not careful, it could backfire on you.

It is surprising to see how after all the code floating around people still find it hard to create random numbers. In a recent piece of code I encountered, the following was used to generate a string of random numbers. The code was written to provide a random string to be passed to a email verifier system - the type wherein a new user when he subscribes to a website needs to verify his email by clicking on a provided link.

He includes a snippet of the code that uses a call to str_shuffle on the set of numbers 1-10 to generate a random number. The only problem with the method is that, when the number gets large enough, PHP would automatically kick it into exponential format - not exactly ideal for an email link. Let this serve as a reminder for any scripts you might make that are similar.

0 comments voice your opinion now!
random string hownotto example email link


blog comments powered by Disqus

Similar Posts

Eran Galperin's Blog: Handling mail and mime in PHP using the Zend Framework

Sameer's Blog: Easy way to build GET query strings in php

Gennady Feldman's Blog: Migration to PHP5 links and articles

Jeff Moore's Blog: Closures (& Lambda Functions) are coming to PHP

ServerGrove Blog: Spooling emails with Symfony2 on VPS and Shared Hosting


Community Events





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


podcast release community voicesoftheelephpant introduction version security laravel update framework series tool language package opinion symfony composer library interview install

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