#include <guiconstantsex.au3>
#include <windowsconstants.au3>
#Include <string.au3>
#Include <crypt.au3>
$Gui = GuiCreate("CryptatorZ",400,200)
$Enc = GuiCtrlCreateButton("Crypta",25,150,175,30)
$Dec = GUICtrlCreateButton("Decrypta",200,150,175,30)
$Pass = GuiCtrlCreateInput("",25,100,250,30)
$Lab = GUICtrlCreateLabel("Livello",300,80,100,15)
$Liv = GUICtrlCreateCombo("RC4",300,100,80,30)
GUICtrlSetData($Liv,"3DES|AES 128|AES 192|AES 256|DES|RC2")
$Lab = GUICtrlCreateLabel("Scegli la Password:",25,80,100,20)
$Input = GUICtrlCreateLabel("Scegli File",25,10,100,15)
$InFile = GUICtrlCreateInput("",25,25,125,25)
$Pre = GUICtrlCreateButton("...",160,25,30,25)
$Output = GUICtrlCreateLabel("Destinazione",200,10,100,15)
$UnFile = GUICtrlCreateInput("",200,25,125,25)
$UnPre = GUICtrlCreateButton("...",335,25,30,25)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $Pre
$File = FileOpenDialog("Scegli File", "", "Tutti i file (*.*
")
If $File <> "" Then GUICtrlSetData($InFile, $File)
Case $UnPre
$File = FileSaveDialog("Destinazione", "", "Tutti i file (*.*
")
If $File <> "" Then GUICtrlSetData($UnFile, $File)
;Criptazione
Case $Enc
$Inp = GUICtrlRead($InFile)
If Not FileExists($Inp) Then
MsgBox(16, "Errore", "il file che hai scelto non esiste!")
ContinueLoop
EndIf
$Out = GUICtrlRead($UnFile)
If $Out="" Then
MsgBox(16,"Errore","Devi scegliere prima la destinazione!")
ContinueLoop
EndIf
$algo = 0
Switch GUICtrlRead($Liv)
Case "3DES"
$algo = $CALG_3DES
Case "DES"
$algo = $CALG_DES
Case "RC2"
$algo = $CALG_RC2
Case "RC4"
$algo = $CALG_RC4
Case "AES 128"
If @OSVersion = "WIN_2000" Then
MsgBox(16, "Errore", "Questo algoritmo non è disponibile per questo sistema operativo!")
ContinueLoop
EndIf
$algo = $CALG_AES_128
Case "AES 192"
If @OSVersion = "WIN_2000" Then
MsgBox(16, "Errore", "Questo algoritmo non è disponibile per questo sistema operativo!")
ContinueLoop
EndIf
$algo = $CALG_AES_192
Case "AES 256"
If @OSVersion = "WIN_2000" Then
MsgBox(16, "Errore", "Questo algoritmo non è disponibile per questo sistema operativo!")
ContinueLoop
EndIf
$algo = $CALG_AES_256
EndSwitch
$Password = GUICtrlRead($Pass)
If $Password="" Then
MsgBox(16,"Errore","Inserisci la password!")
ContinueLoop
EndIf
AdlibRegister("Update",333)
$success=_Crypt_EncryptFile($Inp,$Out,$Password,$algo)
If $success Then
MsgBox(0,"Crypt","Cryptazione effettuata con successo!")
Else
Switch @error
Case 1
MsgBox(16,"Fail","Failed to create key")
Case 2
MsgBox(16,"Fail","Impossibile aprire il file")
Case 3
MsgBox(16,"Fail","Impossibile salvare il file in quella destinazione")
Case 4 or 5
MsgBox(16,"Fail","Errore di criptazione")
EndSwitch
EndIf
;Decriptazione
Case $Dec
$InFile2 = GUICtrlRead($InFile)
If Not FileExists($InFIle2) Then
MsgBox(16, "Errore", "Il file da criptare non esiste!")
ContinueLoop
EndIf
$OutFile2 = GUICtrlRead($UnFIle)
If $OutFile2="" Then
MsgBox(16,"Errore","La destinazione è errata!")
ContinueLoop
EndIf
$algo = 0
Switch GUICtrlRead($Liv)
Case "3DES"
$algo = $CALG_3DES
Case "DES"
$algo = $CALG_DES
Case "RC2"
$algo = $CALG_RC2
Case "RC4"
$algo = $CALG_RC4
Case "AES 128"
If @OSVersion = "WIN_2000" Then
MsgBox(16, "Errore", "Questo algoritmo non è disponibile per questo sistema operativo!")
ContinueLoop
EndIf
$algo = $CALG_AES_128
Case "AES_192"
If @OSVersion = "WIN_2000" Then
MsgBox(16, "Errore", "Questo algoritmo non è disponibile per questo sistema operativo!")
ContinueLoop
EndIf
$algo = $CALG_AES_192
Case "AES_256"
If @OSVersion = "WIN_2000" Then
MsgBox(16, "Errore", "Questo algoritmo non è disponibile per questo sistema operativo!")
ContinueLoop
EndIf
$algo = $CALG_AES_256
EndSwitch
$password2 = GUICtrlRead($Pass)
If $password2="" Then
MsgBox(16,"Errore","Inserisci una password")
ContinueLoop
EndIf
AdlibRegister("Update",333)
$success=_Crypt_DecryptFile($InFile2,$OutFile2,$password2,$algo)
If $success Then
MsgBox(0,"Success","Decriptazione effettuata con successo!")
Else
Switch @error
Case 1
MsgBox(16,"Fail","Failed to create key")
Case 2
MsgBox(16,"Fail","Couldn't open source file")
Case 3
MsgBox(16,"Fail","Couldn't open destination file")
Case 4 or 5
MsgBox(16,"Fail","Encryption error")
EndSwitch
EndIf
AdlibUnRegister("Update")
WinSetTitle($Gui,"","File Encrypter")
EndSwitch
WEnd