[Func] Générateur de mot de passe
Posté : mer. 05 nov. 2008 23:14
J'ai rapidement cherché sur le forum et je pense pas que il y ai un script semblable au mien.
Si oui bah je m'en fou
Edit Tlem : Simplification de la fonction et ajout de la description.
Incorporation d'améliorations suggérées par Iste et Tolf.
Si oui bah je m'en fou

Code : Tout sélectionner
;===============================================================================
; Description: Returns a password string with or without special chars.
; Parameter(s): $PassWordLen - The len of desired password
; $CharFlag - Use special chars in password.
; 0 = No
; 1 = Yes
; Requirement(s): None
; Return Value(s): Return a string.
;
; Author(s): JBnH
; Note(s):
; Examples: MsgBox(64,"Password without special chars", _PassWordGenerate(10, 0))
; MsgBox(64,"Password with special chars", _PassWordGenerate(10, 1))
;===============================================================================
Func _PassWordGenerate($PassWordLen, $CharFlag)
Local $PassWrd, $Global
Local $Char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
Local $SpecChar = "&'_:;,.!@#$%*()-=+[]\/?<>{}^~¤"
If $CharFlag = 1 Then
$Array = StringSplit($Char & $SpecChar, "")
Else
$Array = StringSplit($Char, "")
EndIf
For $X = 1 to $PassWordLen
$PassWrd &= $Array[Random (1, $Array[0], 1)]
Next
Return $PassWrd
EndFunc
Incorporation d'améliorations suggérées par Iste et Tolf.