verschlüsselungsprogramm, es wird keine datei erstellt

  • Hallo,
    ich möchte mittels Autoit ganze Dateien verschlüsselt und habe dafür ein Programm geschrieben:

    [autoit]

    #include <String.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    HotKeySet("{ESC}","_Ende")

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

    Global $pw = "123"
    Global $lvl = 1

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

    $Form1 = GUICreate("Hackrypt", 283, 128, 517, 261)
    $btBrowse1 = GUICtrlCreateButton("Browse", 208, 32, 73, 25)
    $tfPath1 = GUICtrlCreateInput("...", 0, 32, 209, 21)
    $Radio1 = GUICtrlCreateRadio("Radio1", 19, 8, 17, 17)
    $Radio2 = GUICtrlCreateRadio("Radio2", 139, 8, 17, 17)
    $Label1 = GUICtrlCreateLabel("encode", 40, 8, 40, 17)
    $Label2 = GUICtrlCreateLabel("decode", 160, 8, 40, 17)
    $tfPath2 = GUICtrlCreateInput("...", 0, 64, 209, 21)
    $btBrowse2 = GUICtrlCreateButton("Browse", 208, 64, 73, 25)
    $btProgress = GUICtrlCreateButton("Progress", 48, 88, 161, 33)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $btBrowse1
    $path1 = FileOpenDialog("Eingangsdatei",@WindowsDir, "(*)")
    GUICtrlDelete($tfPath1)
    $tfPath1 = GUICtrlCreateInput($path1, 0, 32, 209, 21)
    Case $btBrowse2
    $path2 = FileOpenDialog("Eingangsdatei",@WindowsDir, "(*)")
    GUICtrlDelete($tfPath2)
    $tfPath2 = GUICtrlCreateInput($path2, 0, 64, 209, 21)
    Case $Radio1
    $crypt = 1
    Case $Radio2
    $crypt = 0
    Case $btProgress
    $path1 = GUICtrlRead($tfPath1)
    $path2 = GUICtrlRead($tfPath2)
    _crypt(FileRead($path1),FileRead($path2),$crypt)
    EndSwitch
    WEnd

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

    Func _crypt($txt,$destination,$crypt)
    $crypted = _StringEncrypt($crypt,$txt,$pw,$lvl)
    ;edit: trotzdem keine datei
    FileWrite($destination,$crypted)
    MsgBox(0,"Success!","Successfully encrypted data!",1)
    EndFunc

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

    Func _Ende()
    Exit
    EndFunc

    [/autoit]

    Es wird allerdings keine Datei erstellt.
    Kann mir jemand helfen?
    LG
    Captain09

    2 Mal editiert, zuletzt von Captain09 (6. Januar 2014 um 16:29)

  • Natürlich, in Zeile 49 verschlüsselt du den Datei-Inhalt, aber du musst dann das verschlüsselte wieder in eine Datei schreiben. ;)

    There's a joke that C has the speed and efficieny of assembly language combined with readability of....assembly language. In other words, it's just a glorified assembly language. - Teh Interwebz

    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, you blow off your whole leg. - Bjarne Stroustrup
    Genie zu sein, bedeutet für mich, alles zu tun, was ich will. - Klaus Kinski

  • Genau wie PainTain gesagt hat, nutz doch

    [autoit]

    _Crypt_EncryptFile()

    [/autoit]


    Steve

    [Blockierte Grafik: http://stefan.blagojevic.at/loading.gif]

    Design, Modellbau, CAD <3
    AutoCAD, ArchiCAD, REVIT (ist ein Scheiss, habe aber das Zertifikat)

    Cinema 4D, RuckZuck Statik Programm

    Michael Bay als Architekt


    Da eine Glasfassade! Booom Sichtbeton! Laminiertes Bild auf Mosaiksteinchen! Granit! Granit! Granit! Sichtbetonwand mit 50° Neigung!
    Holzverkleidung erscheint da! Boooooom!

  • sorry, das war nur ein Kopierfehler aus meinem script:

    [autoit]


    #include <String.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    HotKeySet("{ESC}","_Ende")

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

    Global $pw = "123"
    Global $lvl = 1

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

    $Form1 = GUICreate("Hackrypt", 283, 128, 517, 261)
    $btBrowse1 = GUICtrlCreateButton("Browse", 208, 32, 73, 25)
    $tfPath1 = GUICtrlCreateInput("...", 0, 32, 209, 21)
    $Radio1 = GUICtrlCreateRadio("Radio1", 19, 8, 17, 17)
    $Radio2 = GUICtrlCreateRadio("Radio2", 139, 8, 17, 17)
    $Label1 = GUICtrlCreateLabel("encode", 40, 8, 40, 17)
    $Label2 = GUICtrlCreateLabel("decode", 160, 8, 40, 17)
    $tfPath2 = GUICtrlCreateInput("...", 0, 64, 209, 21)
    $btBrowse2 = GUICtrlCreateButton("Browse", 208, 64, 73, 25)
    $btProgress = GUICtrlCreateButton("Progress", 48, 88, 161, 33)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $btBrowse1
    $path1 = FileOpenDialog("Eingangsdatei",@WindowsDir, "(*)")
    GUICtrlDelete($tfPath1)
    $tfPath1 = GUICtrlCreateInput($path1, 0, 32, 209, 21)
    Case $btBrowse2
    $path2 = FileOpenDialog("Eingangsdatei",@WindowsDir, "(*)")
    GUICtrlDelete($tfPath2)
    $tfPath2 = GUICtrlCreateInput($path2, 0, 64, 209, 21)
    Case $Radio1
    $crypt = 1
    Case $Radio2
    $crypt = 0
    Case $btProgress
    $path1 = GUICtrlRead($tfPath1)
    $path2 = GUICtrlRead($tfPath2)
    _crypt(FileRead($path1),FileRead($path2),$crypt)
    EndSwitch
    WEnd

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

    Func _crypt($txt,$destination,$crypt)
    $crypted = _StringEncrypt($crypt,$txt,$pw,$lvl)
    FileWrite($destination,$crypted)
    MsgBox(0,"Success!","Successfully encrypted data!",1)
    EndFunc

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

    Func _Ende()
    Exit
    EndFunc

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

    keine datei wird erstellt

  • [autoit]

    Case $btProgress
    $path1 = GUICtrlRead($tfPath1)
    $path2 = GUICtrlRead($tfPath2)
    _crypt(FileRead($path1),FileRead($path2),$crypt)

    [/autoit]

    Das ist auch Unfug, ausser in der Datei die du im Input angibst steht der Pfad den du letztlich zum speichern verwenden willst, andernfalls hat das fileread beim destination Parameter nichts verloren... :P


    EDIT:

    [autoit]


    Case $btBrowse2
    $path2 = FileOpenDialog("Eingangsdatei",@WindowsDir, "(*)")
    GUICtrlDelete($tfPath2)
    $tfPath2 = GUICtrlCreateInput($path2, 0, 64, 209, 21)

    [/autoit]

    Das hier ist auch unsinnig. Schau dir in der Hilfe mal die Funktion

    [autoit]

    guictrlsetdata

    [/autoit]

    an. Dann kannst du dir das Löschen und Neuerstellen des Controls sparen.

    Einmal editiert, zuletzt von misterspeed (6. Januar 2014 um 16:35)