password generation algo
Moderator: General Moderators
password generation algo
i want some algorithm to generate password for scratch card my card serial # is atrt from 0001 onward pl help me
do you have any ideas on how to do it? i have something that does letters and numbers mixed rather well but i'm not simply going to give you something. show me that you've got a clue as to what you're doing and you need to be pointed in a direction, then i will help you get where you want, and if you're close enough just give you what i have
http://www.evilwalrus.com/viewcode.php?codeEx=535 is what I normally use if I need to create on the fly passwords.
Code: Select all
<?php
for($x=0;$x<32;$x++){
$random = rand(33,105);
$password .= chr($random);
}
echo md5($password);
?>- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Mixing Jason's and Drachlen's solutions, I came into this:
An output:
Specify the length of the password, from 1 (not really) to 32 in random_password function call. If the $length parameter is set to 0, the function returns a 6 to 12 length password.
Cheers,
Scorphus.
Code: Select all
<?
function random_password ($length = 0) {
$dx = mt_rand(0, 32 - $length);
$length_ini = empty($length) ? mt_rand(0, 19) : $dx;
$length_fin = empty($length) ? mt_rand(6, 12) : $length;
for ($x = 0; $x < 32; $x++) {
$random = rand(33, 105);
$password .= chr($random);
}
$password = md5($password);
$password = substr(md5($password), $length_ini, $length_fin);
return $password;
}
echo random_password(10);
echo random_password(8);
echo random_password(6);
echo random_password(4);
?>Code: Select all
5500cc4e2c
8b6ff745
b5ab68
af9cCheers,
Scorphus.