GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   best way to generate a random string? (https://gfy.com/showthread.php?t=1056120)

fris 02-03-2012 09:56 AM

best way to generate a random string?
 
looking to create a string like on pastebin for the entries.

whats the best way to go about this?

current way im doing is using uniqid with some other jazz

Code:

function short_name( $post_name ) {
                global $wpdb, $post;
                if ( !is_object( $post ) )
                        return $post_name;
                $num    = (int) $post->ID;
                $pasteid = md5(uniqid($num, true));
                $slug = dechex(crc32($pasteid));
                return $slug;
 }


k0nr4d 02-03-2012 10:11 AM

nothign wrong with md5(uniqid());
You can maybe use microtime too

PowerCum 02-03-2012 10:38 AM

Compile your apache with mod unique_id and let the web server care about it for you.
On high traffic servers the performance impact is almost nothing. Your solution is considerably slower than apache inique_id and will consume quite more CPU.
Other than that, it's an ok solution.

fris 02-03-2012 10:42 AM

Quote:

Originally Posted by PowerCum (Post 18733033)
Compile your apache with mod unique_id and let the web server care about it for you.
On high traffic servers the performance impact is almost nothing. Your solution is considerably slower than apache inique_id and will consume quite more CPU.
Other than that, it's an ok solution.

ya im only running this at the time of creating a post. so other than that its not used anywhere else.

I thik i have that module installed for expiring links.

grumpy 02-03-2012 11:34 AM

or you can just take a sessionid


All times are GMT -7. The time now is 05:46 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123