PW-Generator

  • Moin Leutz ,
    ich bin noch neu hier und wollte gleich mal was fragen.
    Ich würde gerne in autoit einen pw-generator schreiben.Bloß dieser soll nicht irgend ein pw generieren, sondern
    er soll ein vorgegebenes wort irgendwie verändern. z.B.man gibt das pw "schatz" ein und der pw generator soll daraus dann z.B "ScHaTz"/"SChaTZ"/"sChAtZ" usw... machen.Das Problem ich hab überhaupt kein plan wo ich anfagen sollte. ;(

    Zitat

    Ich weiß auch nicht warum Anfänger immer nach den Sternen greifen. :D


    Vielleicht kann mir jemand einen Tipp geben wo ich anfangen könnte zu suchen. :)

    Kennt jemand vielleicht eine website mit vielen beispielprogrammen?
    freu mich auf antworten :D

    Einmal editiert, zuletzt von Lucas (3. September 2009 um 16:05)

  • Vielleicht so:

    [autoit]


    $input=InputBox("Eingabe","Vorlage eingeben")
    Dim $result=""
    $array=StringSplit($input,"")
    For $i=1 To $array[0]
    If Random(0,1,1) Then
    $result &= StringUpper($array[$i])
    Else
    $result &= StringLower($array[$i])
    EndIf
    Next
    MsgBox(64,"Neues Passwort:",$result)

    [/autoit]


    edit: Falls ich dir erklären soll, wie das funktioniert, schreib mich an :)

    Twitter: @L3viathan2142
    Benutze AutoIt persönlich nicht mehr, da ich keinen Windows-Rechner mehr besitze.

  • Hallo,
    schreibe dein "Passwort" in das Eingabefeld einer

    [autoit]

    inputbox()

    [/autoit]

    . Dann verwendest du eine

    [autoit]

    For to

    [/autoit]

    Schleife und bearbeitest per

    [autoit]

    stringmid()

    [/autoit]

    nacheinander die einzelnen Buchstaben. Mit

    [autoit]

    random()

    [/autoit]

    berechnest du eine Zufallszahl zwischen Null und Eins. Wenn

    [autoit]

    If

    [/autoit]

    diese Zufallszahl Eins ist, dann

    [autoit]

    then

    [/autoit]

    schreibe den Buchstaben per

    [autoit]

    stringupper()

    [/autoit]

    in Großbuchstaben, ansonsten

    [autoit]

    else

    [/autoit]

    lasse den Buchstaben klein.
    So sollte es klappen, viel Spass beim scripten!
    Andy

    Edit: so gehts, wenn man zwischendurch mal nen Kaffee trinken geht, man ist viiieeel zu langsam^^

  • Hier mal ein Beispiel von mir: (kannst dir ja vielleicht was abschaun)

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ;******************************************
    ;Variablen
    ;******************************************

    [/autoit] [autoit][/autoit] [autoit]

    Dim $code
    Dim $alte = ""
    Dim $ver = "1.0.1"
    Dim $name = "Pass_Gen"
    Global $password = ""
    Global $key[7]
    $key[0] = '1234567890'
    $key[1] = 'abcdefghijklmnopqrstuvwxyz'
    $key[2] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    $key[3] = '_'
    $key[4] = '@€µ²³°!§$%&/=|,.-;:_#+*~?\'
    $key[5] = '-'
    $key[6] = '<>()[]'
    Dim $auswahl[7]
    $auswahl[2] = False
    $auswahl[1] = False
    $auswahl[5] = False
    $auswahl[3] = False
    $auswahl[6] = False
    $auswahl[0] = False
    $auswahl[4] = False

    [/autoit] [autoit][/autoit] [autoit]

    ;******************************************
    ;Gui
    ;******************************************

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=c:\users\johannes\desktop\passwort generator\passwort generator.kxf
    $hGui = GUICreate("Passwort Generator v. 1.0.1", 608, 385, 700, 265)
    GUISetIcon("shell32.dll", 45)
    $uppercasecheck = GUICtrlCreateCheckbox("Uppercase: A,B,C,...", 248, 24, 153, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $lowercasecheck = GUICtrlCreateCheckbox("Lowercase: a,b,c,...", 248, 48, 153, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $numberscheck = GUICtrlCreateCheckbox("Numbers: 0,1,2,...", 248, 72, 153, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $minuscheck = GUICtrlCreateCheckbox("Minus: -", 408, 72, 153, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $underlinecheck = GUICtrlCreateCheckbox("Underline: _", 408, 48, 153, 25) ;vorher: 248, 96, 153, 25
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $bracketscheck = GUICtrlCreateCheckbox("Brackets: [,],<,>,...", 408, 24, 153, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $specialcheck = GUICtrlCreateCheckbox("Special: !,%,&,...", 248, 96, 153, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $generate = GUICtrlCreateButton("&Generate", 96, 350, 270, 26, 0)
    $about = GUICtrlCreateButton("&About", 16, 350, 65, 26, 0)
    $exit = GUICtrlCreateButton("&Exit", 528, 350, 65, 26, 0)
    $delete = GUICtrlCreateButton("&Delete", 455, 350, 65, 26, 0)
    $copy = GUICtrlCreateButton("&Copy", 380, 350, 65, 26, 0)
    $anzahlpws = GUICtrlCreateInput("", 152, 30, 63, 21)
    $Group1 = GUICtrlCreateGroup("Generated passwords:", 8, 128, 593, 215)
    $List2 = GUICtrlCreateList("", 16, 146, 577, 188)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $pwlaenge = GUICtrlCreateInput("", 152, 62, 65, 21)
    $Label1 = GUICtrlCreateLabel("Number of passwords:", 16, 32, 134, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Password-length:", 47, 64, 95, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Group2 = GUICtrlCreateGroup("Settings:", 8, 6, 593, 121)
    GUISetState(@SW_SHOW)
    $aboutwin = GUICreate("About - Check Version", 264, 124, 654, 372)
    GUISetIcon("shell32.dll", -278)
    $Button1 = GUICtrlCreateButton("&OK", 8, 88, 67, 25)
    $Label5 = GUICtrlCreateLabel("Version: 1.0.1", 81, 26, 69, 17, $WS_GROUP)
    $Label6 = GUICtrlCreateLabel("Copyright © Johannes Kneip, 2008", 81, 44, 169, 16, $WS_GROUP)
    $Label7 = GUICtrlCreateLabel("Passwort Generator", 81, 9, 97, 16, $WS_GROUP)
    $Label7 = GUICtrlCreateLabel("Email: autoit.report@web.de", 81, 62, 200, 30, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("&Check Version", 110, 88, 120, 25)
    $Icon1 = GUICtrlCreateIcon("shell32.dll", -45, 8, 8, 65, 65, BitOR($SS_NOTIFY, $WS_GROUP))
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    ;**********************************************************
    ;While-Scheife ("zur Abfrage der Benutzertätigkeiten")
    ;**********************************************************

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
    Case $GUI_EVENT_CLOSE
    If $msg[1] = $hGui Then
    GUIDelete($hGui)
    Exit
    Else
    If $msg[1] = $aboutwin Then
    GUISetState(@SW_HIDE, $aboutwin)
    EndIf
    EndIf
    Case $generate
    _Check()
    $numberpasswords = GUICtrlRead($anzahlpws)
    _PasswortCheck($alte)
    _GUICtrlListBox_SetSel($List2, 1)
    Case $pwlaenge
    $read = GUICtrlRead($pwlaenge)
    If $read < 1 Then GUICtrlSetData($pwlaenge, 5)
    Case $copy
    $checked1 = _GUICtrlListBox_GetCurSel($List2)
    $checked2 = _GUICtrlListBox_GetText($List2, $checked1)
    ClipPut($checked2)
    Case $about
    GUISetState(@SW_SHOW, $aboutwin)
    Case $Button1
    GUISetState(@SW_HIDE, $aboutwin)
    Case $exit
    Exit
    Case $Button2
    _UpdateCheck()
    Case $delete
    GUICtrlSetData($List2, "")
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ;***********************************************
    ;"Update-Funktion", prüft auf neueste Version
    ;***********************************************

    [/autoit] [autoit][/autoit] [autoit]

    Func _UpdateCheck()
    InetGet("http://autoit.spacequadrat.de/Downloads/update/update.txt", @TempDir & "\update.txt", 1, 0)
    $file = FileOpen(@TempDir & "\update.txt", 0)
    $line = FileReadLine($file, 1)
    $line3 = FileReadLine($file, 3)
    If $line = $ver Then
    MsgBox(64, "No Update found!", "You got the newest version: (" & $ver & ")")
    FileClose($file)
    FileDelete(@TempDir & "\update.txt")
    Else
    $newver = $line & "_" & $line3
    MsgBox(64, "Update!", "A newer version is available!")
    $fg = MsgBox(4, "Updaten?", "Do you want to download the new version?")
    If $fg = 6 Then
    InetGet("http://autoit.spacequadrat.de/Downloads/" & $newver & "/" & $newver & ".exe",$line3,1,1)
    FileClose($file)
    FileDelete(@TempDir & "\update.txt")
    EndIf
    EndIf
    EndFunc ;==>_UpdateCheck

    [/autoit] [autoit][/autoit] [autoit]

    ;**********************************************************************
    ;"Checkbox-Check-Funktion", prüft welche Checkboxen angeklickt sind
    ;**********************************************************************

    [/autoit] [autoit][/autoit] [autoit]

    Func _Check()
    Dim $codes = ""
    Dim $code = ""
    Dim $i = 0
    $b = GUICtrlRead($bracketscheck)
    If $b = 1 Then $auswahl[6] = True
    If $b = 4 Then $auswahl[6] = False
    $c = GUICtrlRead($lowercasecheck)
    If $c = 1 Then $auswahl[1] = True
    If $c = 4 Then $auswahl[1] = False
    $d = GUICtrlRead($underlinecheck)
    If $d = 1 Then $auswahl[3] = True
    If $d = 4 Then $auswahl[3] = False
    $e = GUICtrlRead($uppercasecheck)
    If $e = 1 Then $auswahl[2] = True
    If $e = 4 Then $auswahl[2] = False
    $f = GUICtrlRead($minuscheck)
    If $f = 1 Then $auswahl[5] = True
    If $f = 4 Then $auswahl[5] = False
    $g = GUICtrlRead($numberscheck)
    If $g = 1 Then $auswahl[0] = True
    If $g = 4 Then $auswahl[0] = False
    $h = GUICtrlRead($specialcheck)
    If $h = 1 Then $auswahl[4] = True
    If $h = 4 Then $auswahl[4] = False
    For $i = 0 To 6 Step 1
    If $auswahl[$i] = True Then
    $codes = $alte & $key[$i]
    Else
    EndIf
    $alte = $codes
    Next
    EndFunc ;==>_Check

    [/autoit] [autoit][/autoit] [autoit]

    ;***********************************************
    ;"Passwort-Funktion", erstellt das Passwort
    ;***********************************************

    [/autoit] [autoit][/autoit] [autoit]

    Func _PasswortCheck($alte)
    For $ou = 0 To $numberpasswords - 1 Step +1
    $password = ''
    For $o = 1 To Number(GUICtrlRead($pwlaenge))
    $password &= StringMid($alte, Random(1, StringLen($alte), 1), 1)
    Next
    GUICtrlSetData($List2, $password)
    GUICtrlSetState($List2, $GUI_FOCUS)
    Next
    EndFunc ;==>_PasswortCheck

    [/autoit]