PWD-GEN

« Older   Newer »
  Share  
france17
CAT_IMG Posted on 11/1/2012, 20:52     +1   -1




PWD-GEN è un generatore di password.Puo generare password di caratteri dell'alfabeto (maiuscoli e minuscoli) e numeri. La lunghezza la si imposta tramite radiobutton.
un grazie ad Aaly per la risoluzione di un intoppo. :)



CODICE
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiEdit.au3>

#Region ### START Koda GUI section ### Form=
$hGUI = GUICreate("PWD-GEN | Password Generator", 430, 200, 361, 371, -1, BitOR($WS_EX_TRANSPARENT,$WS_EX_WINDOWEDGE))
$hFile = GUICtrlCreateMenu("File")
$hEsci = GUICtrlCreateMenuItem("Esci", $hFile)
$hInfo = GUICtrlCreateMenu("Info")
$hCredits = GUICtrlCreateMenuItem("Credits", $hInfo)
$pwd = GUICtrlCreateEdit("", 24, 140, 377, 21, BitOR($ES_CENTER,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_BORDER))
$generate = GUICtrlCreateButton("Genera", 305, 60, 97, 33, $BS_CENTER)
$gruppoTipo = GUICtrlCreateGroup("Tipo Caratteri", 24, 20, 129, 97)
$TipoMaiuscole=GUICtrlCreateRadio("Solo maiuscole",30,35)
$TipoMinuscole=GUICtrlCreateRadio("Solo minuscole",30,55)
$TipoNumeri=GUICtrlCreateRadio("Solo numeri",30,75)
$TipoMinMai=GUICtrlCreateRadio("Minuscole e Maiuscole",30,95)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$gruppoLen = GUICtrlCreateGroup("Lunghezza", 158, 20, 145, 97)
$Len8=GUICtrlCreateRadio("8",164,35)
$Len16=GUICtrlCreateRadio("16",164,55)
$Len24=GUICtrlCreateRadio("24",164,75)
$Len32=GUICtrlCreateRadio("32",164,95)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
               Case $GUI_EVENT_CLOSE
                       Exit
               Case $hCredits
                       _info()
               Case $hEsci
                       Exit
               Case $generate
                                       If GUICtrlRead($TipoMaiuscole) = $GUI_CHECKED Then        ; controllo tipo carattere scelto
                                               $tipo=1
                                       ElseIf GUICtrlRead($TipoMinuscole) = $GUI_CHECKED Then
                                               $tipo=2
                                       ElseIf GUICtrlRead($TipoNumeri) = $GUI_CHECKED Then
                                               $tipo=3
                                       ElseIf GUICtrlRead($TipoMinMai) = $GUI_CHECKED Then
                                               $tipo=4
                                       Else
                                               $tipo=0
                                       EndIf        
                                       If GUICtrlRead($Len8) = $GUI_CHECKED Then        ; controllo numeri caratteri scelto
                                               $len=8
                                       ElseIf GUICtrlRead($Len16) = $GUI_CHECKED Then
                                               $len=16
                                       ElseIf GUICtrlRead($Len24) = $GUI_CHECKED Then
                                               $len=24
                                       ElseIf GUICtrlRead($Len32) = $GUI_CHECKED Then
                                               $len=32
                                       Else
                                               $len=0
                                       EndIf
                                       If $tipo=0 Or $len=0 Then
                                               MsgBox(64,"Ripetere","Ripetere");
                                       EndIf
                                       _GeneraPwd($tipo,$len)
       EndSwitch
WEnd



Func _info()
       $info=Guicreate("Informazioni",200,100)
       GUISetState(@SW_SHOW,$info)
       $autore=GUICtrlCreateLabel("Autore: france17",15,10,100,20)
       GUICtrlCreateLabel("PWD----GEN",15,30,180,100)
       GUICtrlSetFont(-1,20)
       $versione=GUICtrlCreateLabel("Versione: 1.0.0",95,70,100,20)
       _visualizzazione($info)
EndFunc


Func _visualizzazione($gui)
               GUISetState(@SW_SHOW,$gui)
               While 1
               $get=GUIGetMsg()
                       Switch $get
                               Case -3
                                       GUIDelete($gui)
                                       ExitLoop
                                       Exit
                       EndSwitch
               WEnd
EndFunc
       

Func _GeneraPwd($tipo,$len)
       Local $chrUpper[26],$chrLower[26], $chrNumbers[10],$chrMinMai[52],$chr[32]
       
       ;PREPARO ARRAY MAIUSCOLE
       $c=0
       For $i=65 To 90 Step 1
               $chrUpper[$c]=Chr($i)
               $c+=1
       Next
       ;PREPARO ARRAY MINUSCOLE
       $c=0
       For $i=97 To 122 Step 1
               $chrLower[$c]=Chr($i)
               $c+=1
       Next
       ;PREPARO ARRAY NUMERI
       $c=0
       For $i=48 To 57 Step 1
               $chrNumbers[$c]=Chr($i)
               $c+=1
       Next
       ;PREPARO ARRAY MINUSCOLE E MAIUSCOLE
       $c=0
       For $i=65 To 90  Step 1
               $chrMinMai[$c]=Chr($i)
               $c+=1
       Next
       For $i=97 To 122 Step 1
               $chrMinMai[$c]=Chr($i)
               $c+=1
       Next
       ;--------------------------------------------------------------------
       $x=0
       _GUICtrlEdit_SetText($pwd,""); resetta la password
       For $i=0 To $len-1 Step 1
               $x=0
               If $tipo=1 Then
                       $x=Int(Random(0,25))
                       $chr[$i]=$chrUpper[$x];maiuscole
               ElseIf $tipo=2 Then
                       $x=Int(Random(0,25))
                       $chr[$i]=$chrLower[$x];minuscole
               ElseIf $tipo=3 Then
                       $x=Int(Random(0,9))
                       $chr[$i]=$chrNumbers[$x];numeri
               ElseIf $tipo=4 Then
                       $x=Int(Random(0,42))
                       $chr[$i]=$chrMinMai[$x]; maiuscole e minuscole
               EndIf
               _GUICtrlEdit_InsertText($pwd,$chr[$i]); inserisce il carattere
       Next
EndFunc


#cs
GENERA PASSWORD BY Aaly

Func _GeneraPwd($tipo,$len)
       If GUICtrlRead($pwd) <> "" Then GUICtrlSetData($pwd, "") ;Se c'è scritto qualcosa lo elimina

       If $tipo = 1 Then                ;Maiuscole
                       For $i = 1 To $len Step 1
                               _GUICtrlEdit_AppendText($pwd, Chr(Random(65,90,1)))
                       Next

               ElseIf $tipo = 2 Then         ;Minuscole
                       For $i = 1 To $len Step 1
                               _GUICtrlEdit_AppendText($pwd, Chr(Random(97,122,1)))
                       Next

               ElseIf $tipo = 3 Then         ;Numeri
                       For $i = 1 To $len Step 1
                               _GUICtrlEdit_AppendText($pwd, Chr(Random(48,57,1)))
                       Next

               ElseIf $tipo = 4 Then         ;Minuscole e maiuscole
                       For $i = 1 To $len Step 1
                               ;Genera un valore Random da 0 o 1
                               If Random(0,1,1) = 0 Then        ;Se il valore generato è 0..
                                       _GUICtrlEdit_AppendText($pwd, Chr(Random(65,90,1)))        ;Aggiunge una lettera Maiuscola Random
                               Else                                                ;Se il valore generato è diverso da 0(cioè 1)..
                                       _GUICtrlEdit_AppendText($pwd, Chr(Random(97,122,1)))        ;Aggiunge una lettera Minuscola Random
                               EndIf
                       Next
               EndIf
       Return
EndFunc

#ce


Edited by france17 - 11/1/2012, 21:05
 
Top
I.Ren
CAT_IMG Posted on 11/1/2012, 20:56     +1   -1




ho dato solo una letta al codice.. ma l'identazione? è una mezza bestemmia da leggere : D

cmq bravo
 
Top
france17
CAT_IMG Posted on 11/1/2012, 20:57     +1   -1




l'indentazione c'è...è che qui sul forum non l''ha mantenuto formattato il codice...se vuoi lo posto su pastebin
 
Top
*Sym98*
CAT_IMG Posted on 11/1/2012, 21:01     +1   -1




CITAZIONE (france17 @ 11/1/2012, 20:57) 
l'indentazione c'è...è che qui sul forum non l''ha mantenuto formattato il codice...se vuoi lo posto su pastebin

Prova a metterlo sotto [CODE]. ;)
 
Top
I.Ren
CAT_IMG Posted on 11/1/2012, 21:05     +1   -1




ok ora è decente e si può leggere, ora lo guardo : D
 
Top
france17
CAT_IMG Posted on 11/1/2012, 21:05     +1   -1




CITAZIONE (*Sym98* @ 11/1/2012, 21:01) 
CITAZIONE (france17 @ 11/1/2012, 20:57) 
l'indentazione c'è...è che qui sul forum non l''ha mantenuto formattato il codice...se vuoi lo posto su pastebin

Prova a metterlo sotto [CODE]. ;)

grazie =)
 
Top
I.Ren
CAT_IMG Posted on 11/1/2012, 21:24     +1   -1




CODICE
Int(Random(0,25))


cosa serve convertirlo ad un intero quando basta che metti Random(0,25,1)? cmq vabbè, è lo stesso

un'altra roba: al posto di generare l'array dell'alfabeto, perchè non usi i codici ascii?
 
Top
CAT_IMG Posted on 11/1/2012, 21:26     +1   -1

So implementare gli object

Group:
Admin
Posts:
1,215
Reputazione:
+150

Status:


CITAZIONE (I.Ren @ 11/1/2012, 21:24) 
CODICE
Int(Random(0,25))


cosa serve convertirlo ad un intero quando basta che metti Random(0,25,1)? cmq vabbè, è lo stesso

un'altra roba: al posto di generare l'array dell'alfabeto, perchè non usi i codici ascii?

Cito, comunque bravo, è sempre utile averne uno a portata di mano!
 
Top
Aaly
CAT_IMG Posted on 11/1/2012, 21:35     +1   -1




;)
 
Top
*Sym98*
CAT_IMG Posted on 11/1/2012, 21:47     +1   -1




CITAZIONE (france17 @ 11/1/2012, 21:05) 
CITAZIONE (*Sym98* @ 11/1/2012, 21:01) 
Prova a metterlo sotto [CODE]. ;)

grazie =)

E di che? :)
 
Top
bradipooso
CAT_IMG Posted on 11/1/2012, 21:54     +1   -1




 
Top
»Master
CAT_IMG Posted on 12/1/2012, 01:35     +1   -1




buono, bravo :)
 
Top
france17
CAT_IMG Posted on 12/1/2012, 15:29     +1   -1




grazie a tutti...ora mi metto a lavorare con i file!!!
 
Top
»Master
CAT_IMG Posted on 12/1/2012, 22:13     +1   -1




buona fortuna :)
 
Top
13 replies since 11/1/2012, 20:52   278 views
  Share