![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,372
|
php question, best way for random numbers?
Whats the best way for random number generation?
this is what im using now Code:
<? mt_srand ((double) microtime() * 1000000); $random = mt_rand(1,100); echo $random; ?>
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence. ![]() WP Stuff |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Too lazy to set a custom title
Join Date: Dec 2004
Posts: 17,513
|
not sure but im sure our channel coders will know
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Too lazy to set a custom title
Join Date: Jan 2002
Location: Holland
Posts: 9,870
|
you dont need the mt_srand ((double) microtime() * 1000000);
Its build in in the mt_rand
__________________
Don't let greediness blur your vision | You gotta let some shit slide icq - 441-456-888 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
sex dwarf
Join Date: May 2002
Posts: 17,860
|
Quote:
mt_rand() will do for most purposes, but if you need pseudo-random data for purposes related to cryptography, keep in mind that mt_rand uses a mersenne twister, which is rather weak. So, in those cases, getting your pseudo-random data from /dev/urandom is a better option.
__________________
/(bb|[^b]{2})/ |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
I believe that you don't really need to use mt_srand with php 5.2.1+
You could use uniqid as a seed, or data from /dev/random
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
True, but there was a fuss about it being insecure until 5.2.1+ I think
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,372
|
im just getting a random number for random image headers, have 10 headers, want to rotate through them
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence. ![]() WP Stuff |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 | |
sex dwarf
Join Date: May 2002
Posts: 17,860
|
Quote:
The other stuff only comes into play when dealing with things where security is an issue, like when a forgotten admin password of a site gets reset on request (which actually was a security hole in Joomla and WP).
__________________
/(bb|[^b]{2})/ |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | |
Too lazy to set a custom title
Industry Role:
Join Date: Mar 2006
Location: Argentina
Posts: 25,924
|
Quote:
$image = rand(1,10); echo "<img src=\"$image.jpg\" width=\"\" height=\"\" alt=\"\" />"; ?> ![]()
__________________
Beautiful And Usable Web Design Creations For The Adult Industry Since 2003
I'm Yuu, Designer and Content Producer Paysites - Affiliate Programs - Dating & Cam Sites - Mainstream Projects - Tube Sites - Banners - Wordpress Themes - NATs integration - Landing Pages Check my Portfolio and Content Production Offers |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Guest
Posts: n/a
|
Like above, rand() will work fine for what you need.
|
![]() ![]() ![]() ![]() ![]() |