Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

GÉNÉRATEUR DE MOTS DE PASSES ALÉATORES


Information sur la source

Catégorie :Maths & Algorithmes Niveau : Débutant Date de création : 11/06/2003 Date de mise à jour : 11/06/2003 21:02:29 Vu / téléchargé: 3 661 / 208

Note :
10 / 10 - par 1 personne
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (5)
Ajouter un commentaire et/ou une note

Description

Je crois que j'ai dérivé ce script d'un autre, mais voilà, je l'ai améliorer pour vous présenter aujourd'hui un générateur de mots de passes aléatoires !

Vous pouvez spécifier le nombre de caractères voulus (de 4 à 16) et les caractères à inclure (majuscules on/off, miniscules on/off, chiffres on/off, caractères spéciaux on/off). Il vous retourne une valeur aléatoire et le nombre de valeurs différentes possibles.
 

Source

  • <center>
  • <H3>Générateur de mot de passe aléatoires</H3>
  • </center>
  • <br>
  • <?
  • if (!$length){ $length = '8'; }
  • if (!$withchar){ $withchar = 'no'; }
  • if (!$lowers){ $lowers = 'yes'; }
  • if (!$uppers){ $uppers = 'yes'; }
  • if (!$nums){ $nums = 'yes'; }
  • if ($withchar == 'no' AND $lowers == 'no' AND $uppers == 'no' AND $nums == 'no'){ print("<b><font color=red>Erreur:</font> Vous devez faire un choix<BR><HR>Nous vous suggérons de choisir ce que vous ferez de ce mot de passe avant de faire une sélection<HR></b>"); exit; }
  • if ($lowers == 'yes'){$char[] = 'a'; $char[] = 'b'; $char[] = 'c'; $char[] = 'd';$char[] = 'e';$char[] = 'f';$char[] = 'g';$char[] = 'h';$char[] = 'i';$char[] = 'j';$char[] = 'k';
  • $char[] = 'l';$char[] = 'm';$char[] = 'n';$char[] = 'o';$char[] = 'p';$char[] = 'q';$char[] = 'r';$char[] = 's';$char[] = 't';$char[] = 'u';$char[] = 'v';
  • $char[] = 'w';$char[] = 'x';$char[] = 'y';$char[] = 'z';}
  • if ($uppers == 'yes'){$char[] = 'A';$char[] = 'B';$char[] = 'C';$char[] = 'D';$char[] = 'E';$char[] = 'F';
  • $char[] = 'G';$char[] = 'H';$char[] = 'I';$char[] = 'J';$char[] = 'K';$char[] = 'L';$char[] = 'M';$char[] = 'N';$char[] = 'O';$char[] = 'P';
  • $char[] = 'Q';$char[] = 'R';$char[] = 'S';$char[] = 'T';$char[] = 'U';$char[] = 'V';$char[] = 'W';$char[] = 'X';$char[] = 'Y';$char[] = 'Z';}
  • if ($nums == 'yes'){$char[] = '0';$char[] = '1';$char[] = '2';$char[] = '3';$char[] = '4';$char[] = '5';$char[] = '6';$char[] = '7';$char[] = '8';$char[] = '9';}
  • if ($withchar == 'yes'){$char[] = '!';$char[] = '@';$char[] = '$';$char[] = '^';$char[] = '+';$char[] = '|';$char[] = '>';$char[] = '<';}
  • $num = count($char);$num -= 1;
  • for ($i = 0; $i < 9; $i++){
  • srand((double)microtime()*1000000);
  • $randnum = rand(0,$num);
  • $password .= "$char[$randnum]";
  • $randnum = rand(0,$num);
  • $password .= "$char[$randnum]";}
  • ?>
  • <script language="Javascript">
  • <!--
  • var copytoclip=1
  • function SelectAndCopy(theField) {
  • var val=eval("document."+theField)
  • val.focus()
  • val.select()
  • if (document.all&toclip==1){
  • textrange=val.createTextRange()
  • textrange.execCommand("Copy")
  • window.status="Password highlighted and copied to clipboard!"
  • setTimeout("window.status=''",1800)
  • }
  • }
  • //-->
  • </script>
  • <CENTER>
  • <BR><BR>
  • [<a href="<? print($PHP_SELF); ?>?length=4&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">4 char</a>] [<a href="<? print($PHP_SELF); ?>?length=6&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">6 char</a>] [<a href="<? print($PHP_SELF); ?>?length=8&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">8 char</a>] [<a href="<? print($PHP_SELF); ?>?length=10&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">10 char</a>] [<a href="<? print($PHP_SELF); ?>?length=12&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">12 char</a>] [<a href="<? print($PHP_SELF); ?>?length=14&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">14 char</a>] [<a href="<? print($PHP_SELF); ?>?length=16&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">16 char</a>]
  • <BR><BR><BR>
  • <FORM name="form1">
  • <noscript>
  • <a href="<? print("$PHP_SELF?$QUERY_STRING"); ?>">Generer un Nouveau Password</a>
  • </noscript>
  • <BR><input type="text" value="<?
  • $password = substr("$password",0,$length);
  • print($password);
  • ?>" name="select" size="40" maxlength="<? print($length); ?>">
  • </FORM>
  • <BR><BR>
  • <center>nombre de possibilités = <?php echo $length; ?><sup><?php echo count($char); ?></sup> = <?php echo pow ($length, count($char)); ?></center>
  • <BR><BR><BR><center>
  • <BR>
  • Caractères Speciaux : |<? if ($withchar == 'no'){ print("<a href=$PHP_SELF?length=$length&withchar=yes&lowers=$lowers&uppers=$uppers&nums=$nums><u>On</u></a>"); } else { print("<b>On</b>"); } ?> | <? if ($withchar == 'yes'){ print("<a href=$PHP_SELF?length=$length&withchar=no&lowers=$lowers&uppers=$uppers&nums=$nums><u>Off</u></a>"); } else { print("<b>Off</b>"); } ?> |
  • Caractères Majuscules : |<? if ($uppers == 'no'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=$lowers&uppers=yes&nums=$nums><u>On</u></a>"); } else { print("<b>On</b>"); } ?> | <? if ($uppers == 'yes'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=$lowers&uppers=no&nums=$nums><u>Off</u></a>"); } else { print("<b>Off</b>"); } ?> |
  • Caractères Minuscules : |<? if ($lowers == 'no'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=yes&uppers=$uppers&nums=$nums><u>On</u></a>"); } else { print("<b>On</b>"); } ?> | <? if ($lowers == 'yes'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=no&uppers=$uppers&nums=$nums><u>Off</u></a>"); } else { print("<b>Off</b>"); } ?> |
  • Chiffres : |<? if ($nums == 'no'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=$lowers&uppers=$uppers&nums=yes><u>On</u></a>"); } else { print("<b>On</b>"); } ?> | <? if ($nums == 'yes'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=$lowers&uppers=$uppers&nums=no><u>Off</u></a>"); } else { print("<b>Off</b>"); } ?> |
  • <BR>
  • </center>
								<center>
									<H3>Générateur de mot de passe aléatoires</H3>
								</center>
								<br>
<? 
if (!$length){ $length = '8'; } 
if (!$withchar){ $withchar = 'no'; } 
if (!$lowers){ $lowers = 'yes'; } 
if (!$uppers){ $uppers = 'yes'; } 
if (!$nums){ $nums = 'yes'; } 
if ($withchar == 'no' AND $lowers == 'no' AND $uppers == 'no' AND $nums == 'no'){ print("<b><font color=red>Erreur:</font> Vous devez faire un choix<BR><HR>Nous vous suggérons de choisir ce que vous ferez de ce mot de passe avant de faire une sélection<HR></b>"); exit; } 
if ($lowers == 'yes'){$char[] = 'a'; $char[] = 'b'; $char[] = 'c'; $char[] = 'd';$char[] = 'e';$char[] = 'f';$char[] = 'g';$char[] = 'h';$char[] = 'i';$char[] = 'j';$char[] = 'k'; 
$char[] = 'l';$char[] = 'm';$char[] = 'n';$char[] = 'o';$char[] = 'p';$char[] = 'q';$char[] = 'r';$char[] = 's';$char[] = 't';$char[] = 'u';$char[] = 'v'; 
$char[] = 'w';$char[] = 'x';$char[] = 'y';$char[] = 'z';} 
if ($uppers == 'yes'){$char[] = 'A';$char[] = 'B';$char[] = 'C';$char[] = 'D';$char[] = 'E';$char[] = 'F'; 
$char[] = 'G';$char[] = 'H';$char[] = 'I';$char[] = 'J';$char[] = 'K';$char[] = 'L';$char[] = 'M';$char[] = 'N';$char[] = 'O';$char[] = 'P'; 
$char[] = 'Q';$char[] = 'R';$char[] = 'S';$char[] = 'T';$char[] = 'U';$char[] = 'V';$char[] = 'W';$char[] = 'X';$char[] = 'Y';$char[] = 'Z';} 
if ($nums == 'yes'){$char[] = '0';$char[] = '1';$char[] = '2';$char[] = '3';$char[] = '4';$char[] = '5';$char[] = '6';$char[] = '7';$char[] = '8';$char[] = '9';} 
if ($withchar == 'yes'){$char[] = '!';$char[] = '@';$char[] = '$';$char[] = '^';$char[] = '+';$char[] = '|';$char[] = '>';$char[] = '<';} 
$num = count($char);$num -= 1; 
for ($i = 0; $i < 9; $i++){ 
srand((double)microtime()*1000000); 
$randnum = rand(0,$num); 
$password .= "$char[$randnum]"; 
$randnum = rand(0,$num); 
$password .= "$char[$randnum]";} 
?>
<script language="Javascript"> 
<!-- 
var copytoclip=1 
function SelectAndCopy(theField) { 
var val=eval("document."+theField) 
val.focus() 
val.select() 
if (document.all&toclip==1){ 
textrange=val.createTextRange() 
textrange.execCommand("Copy") 
window.status="Password highlighted and copied to clipboard!" 
setTimeout("window.status=''",1800) 
} 
} 
//--> 
</script>
<CENTER>
<BR><BR>
[<a href="<? print($PHP_SELF); ?>?length=4&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">4 char</a>] [<a href="<? print($PHP_SELF); ?>?length=6&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">6 char</a>] [<a href="<? print($PHP_SELF); ?>?length=8&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">8 char</a>] [<a href="<? print($PHP_SELF); ?>?length=10&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">10 char</a>] [<a href="<? print($PHP_SELF); ?>?length=12&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">12 char</a>] [<a href="<? print($PHP_SELF); ?>?length=14&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">14 char</a>] [<a href="<? print($PHP_SELF); ?>?length=16&withchar=<? print($withchar); ?>&lowers=<? print($lowers); ?>&uppers=<? print($uppers); ?>&nums=<? print($nums); ?>">16 char</a>] 
<BR><BR><BR> 
<FORM name="form1"> 

<noscript> 
<a href="<? print("$PHP_SELF?$QUERY_STRING"); ?>">Generer un Nouveau Password</a> 
</noscript> 
<BR><input type="text" value="<? 
$password = substr("$password",0,$length); 
print($password); 

?>" name="select" size="40" maxlength="<? print($length); ?>"> 
</FORM> 
<BR><BR>
<center>nombre de possibilités = <?php echo $length; ?><sup><?php echo count($char); ?></sup>  = <?php echo pow ($length, count($char)); ?></center>
<BR><BR><BR><center> 
<BR> 
Caractères Speciaux : |<? if ($withchar == 'no'){ print("<a href=$PHP_SELF?length=$length&withchar=yes&lowers=$lowers&uppers=$uppers&nums=$nums><u>On</u></a>"); } else { print("<b>On</b>"); } ?> | <? if ($withchar == 'yes'){ print("<a href=$PHP_SELF?length=$length&withchar=no&lowers=$lowers&uppers=$uppers&nums=$nums><u>Off</u></a>"); } else { print("<b>Off</b>"); } ?> | 
Caractères Majuscules : |<? if ($uppers == 'no'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=$lowers&uppers=yes&nums=$nums><u>On</u></a>"); } else { print("<b>On</b>"); } ?> | <? if ($uppers == 'yes'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=$lowers&uppers=no&nums=$nums><u>Off</u></a>"); } else { print("<b>Off</b>"); } ?> | 
Caractères Minuscules : |<? if ($lowers == 'no'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=yes&uppers=$uppers&nums=$nums><u>On</u></a>"); } else { print("<b>On</b>"); } ?> | <? if ($lowers == 'yes'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=no&uppers=$uppers&nums=$nums><u>Off</u></a>"); } else { print("<b>Off</b>"); } ?> | 
Chiffres : |<? if ($nums == 'no'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=$lowers&uppers=$uppers&nums=yes><u>On</u></a>"); } else { print("<b>On</b>"); } ?> | <? if ($nums == 'yes'){ print("<a href=$PHP_SELF?length=$length&withchar=$withchar&lowers=$lowers&uppers=$uppers&nums=no><u>Off</u></a>"); } else { print("<b>Off</b>"); } ?> | 
<BR> 
</center>  

Fichier Zip

Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip

Commentaires et avis

signaler à un administrateur
Commentaire de matrey le 12/06/2003 10:28:59

autre solution : md5(time), et tu prends le nbre de caractères que tu veux...

signaler à un administrateur
Commentaire de Totofweb le 12/06/2003 12:01:06

oui, mais là on ne choisis pas les caractères. Dans mon script il y a plus de convivialité et de possibilités. Mais bon, chaque programmeur à ses trucs, et on n'aime pas qu'on lui impose ceux des autres, ça je le comprends

signaler à un administrateur
Commentaire de Totofweb le 12/06/2003 19:35:14

signaler à un administrateur
Commentaire de mehdibou le 18/06/2003 22:48:40

signaler à un administrateur
Commentaire de ludovicanceaux le 29/01/2006 15:31:51

ca mank grav de commentaire!!!!!!

Ajouter un commentaire



Nos sponsors

Sondage...

CalendriCode

Juillet 2009
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
2728293031  

Consulter la suite du CalendriCode

Comparez les prix Nouvelle version

Photothèque Nouveau !



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,265 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.