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.

Link to comment
Share on other sites

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);

?>

Link to comment
Share on other sites

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); 
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.