Jump to content

Random 35 character word


forumnz

Recommended Posts

plenty of different ways for this question

 

think of valid chars as cards.

u can have it do one of 2 methods

1) Just use the cards, no repeats of cards, shuffle and deal 35 cards.

2) Put the cards in seperate piles, and open a few more decks and put them on each pile. pick a random pile, draw a card, and repeat 34 more times. this one is simple to do.

Here's a quick way of doing it but only the last three characters might be in uppercase. You can change it to pick a random number of characters in the token to change to uppercase.

 

<?php

$token = substr(md5(uniqid(rand(), true)) . strtoupper(md5(uniqid(rand(), true))), 0, 35);

?>

something like this?

<?php

/**
* @param int $length - max 40 chars (sha1 length)
* @return string
*/
function getRandomPassword($length) {
return substr(
	base64_encode( sha1( mt_rand() ) ),
	0,
	$length);
}

// i used base64 encoding becouse it's convert any
// data to letters (lowers and uppers) and numbers 
echo getRandomPassword(35); 
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.