Random Number String & Password generator function

Random Number String generator function

function r($len){
$keyset = “abcdefghijklmnopqrstuvwxyz0123456789”;
$randkey = “”;
for ($i=0; $i<$len; $i++)
{
$randkey = $randkey . $keyset[mt_rand(0, strlen($keyset)-1)];
}
return $randkey;
}

Strong Password generator function

function generatePassword($length=9, $strength=0) {
$vowels = ‘aeuy’;
$consonants = ‘bdghjmnpqrstvz’;
if ($strength & 1) {
$consonants .= ‘BDGHJLMNPQRSTVWXZ’;
}
if ($strength & 2) {
$vowels .= “AEUY”;
}
if ($strength & 4) {
$consonants .= ‘23456789’;
}
if ($strength & 8) {
$consonants .= ‘@#$%’;
}

$password = ”;
$alt = time() % 2;
for ($i = 0; $i < $length; $i++) {
if ($alt == 1) {
$password .= $consonants[(rand() % strlen($consonants))];
$alt = 0;
} else {
$password .= $vowels[(rand() % strlen($vowels))];
$alt = 1;
}
}
return $password;
}

If you like the post & want to get more then Subscribe our blog posts. Subscribe SunwareTech.net RSS Feed Facebook Twitter Email

Both comments and pings are currently closed.

6 Responses to “Random Number String & Password generator function”

  1. Hello! I just would like to give a huge thumbs up for the great info you have here on this post. I will be coming back to your blog for more soon.

  2. Hey would you mind letting me know which hosting company you’re using? I’ve loaded your blog in 3 completely different internet browsers and I must say this blog loads a lot faster then most. Can you recommend a good hosting provider at a reasonable price? Many thanks, I appreciate it!

  3. Pharmc192 says:

    Hello! bgfeeag interesting bgfeeag site! I’m really like it! Very, very bgfeeag good!

  4. beat maker says:

    It site has got lots of very useful things on it! Cheers for helping me!

  5. Its hard to find good help…

    I am forever saying that its hard to procure good help, but here is…

  6. Informative and precise…

    Its difficult to find informative and accurate information but here I noted…

Copyright © Sunware Technologies - Your web partner