/ Forside / Teknologi / Udvikling / PHP / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
PHP
#NavnPoint
rfh 3959
natmaden 3372
poul_from 3310
funbreak 2700
stone47 2230
Jin2k 1960
Angband 1743
Bjerner 1249
refi 1185
10  Interkril.. 1146
Random password
Fra : Asbjørn Sloth Tønnes~


Dato : 04-05-01 16:16

Hvad gøre jeg galt?

<?
function RandomPass() {
$tegn = array("q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v",
"b", "n", "m", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V",
"B", "N", "M", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
srand((double) microtime() * 1000000);
$stoerrelse = sizeof($tegn);
$stoerrelse2 = $stoerrelse - 1;
$rantegnnr = rand(0, $stoerrels2);
$ranpass = "";
for ($i = 0; $i < 10; $i++) {
$ranpass = $ranpass + $tegn[$rantegnnr];
}
return $ranpass;
}
?>


 
 
Johan (04-05-2001)
Kommentar
Fra : Johan


Dato : 04-05-01 16:23

> <?
> function RandomPass() {
> $tegn = array("q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s",
"d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v",
> "b", "n", "m", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S",
"D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V",
> "B", "N", "M", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
> srand((double) microtime() * 1000000);
> $stoerrelse = sizeof($tegn);
> $stoerrelse2 = $stoerrelse - 1;
> $rantegnnr = rand(0, $stoerrels2);
> $ranpass = "";
> for ($i = 0; $i < 10; $i++) {
> $ranpass = $ranpass + $tegn[$rantegnnr];
> }
> return $ranpass;
> }
> ?>

Prøv istedet:
function Password($length=8) {
$Pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$Pool .= "abcdefghijklmnopqrstuvwxyz";
$Pool .= "1234567890";
for ($index = 0; $index < $length; $index++) {
$sid .= substr($Pool, rand()%(strlen($Pool)), 1);
}
return ($password);
}
echo Password(8);

mvh

Johan



Johan (04-05-2001)
Kommentar
Fra : Johan


Dato : 04-05-01 16:28

> Prøv istedet:
> function Password($length=8) {
> $Pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> $Pool .= "abcdefghijklmnopqrstuvwxyz";
> $Pool .= "1234567890";
> for ($index = 0; $index < $length; $index++) {
> $sid .= substr($Pool, rand()%(strlen($Pool)), 1);
> }
> return ($password);
> }
> echo Password(8);

Ups lille fejl...
function Password($length=8) {
$Pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$Pool .= "abcdefghijklmnopqrstuvwxyz";
$Pool .= "1234567890";
for ($index = 0; $index < $length; $index++) {
$password .= substr($Pool, rand()%(strlen($Pool)), 1);
}
return ($password);
}
echo Password(8);

så skulle den virke... sæt selv det antal tegn du ønsker passworded på...

mvh

Johan



Asbjørn Sloth Tønnes~ (04-05-2001)
Kommentar
Fra : Asbjørn Sloth Tønnes~


Dato : 04-05-01 16:38

Tak for hjælpen
"Johan" <tcr480@ofir.dk> skrev i en meddelelse news:9cuhsa$np$1@news.inet.tele.dk...
> > Prøv istedet:
> > function Password($length=8) {
> > $Pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> > $Pool .= "abcdefghijklmnopqrstuvwxyz";
> > $Pool .= "1234567890";
> > for ($index = 0; $index < $length; $index++) {
> > $sid .= substr($Pool, rand()%(strlen($Pool)), 1);
> > }
> > return ($password);
> > }
> > echo Password(8);
>
> Ups lille fejl...
> function Password($length=8) {
> $Pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> $Pool .= "abcdefghijklmnopqrstuvwxyz";
> $Pool .= "1234567890";
> for ($index = 0; $index < $length; $index++) {
> $password .= substr($Pool, rand()%(strlen($Pool)), 1);
> }
> return ($password);
> }
> echo Password(8);
>
> så skulle den virke... sæt selv det antal tegn du ønsker passworded på...
>
> mvh
>
> Johan
>
>


Søg
Reklame
Statistik
Spørgsmål : 177523
Tips : 31968
Nyheder : 719565
Indlæg : 6408675
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste