Jump to content

_Crypt_DecryptFile() problem


unuro
 Share

Recommended Posts

Does anyone know what the problem is the script, why not work? :(

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Crypt.au3>
$Form1 = GUICreate("Form1", 260, 52, 471, 268)
$Button1 = GUICtrlCreateButton("Lock All Files", 8, 16, 99, 25)
$Button2 = GUICtrlCreateButton("Unlock All Files", 120, 16, 107, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$Folder = FileSelectFolder("Choose a folder.", "", 1, @DesktopDir,$Form1)
If Not @error Then
$List1 = _FileListToArray($Folder, "*", 1)
For $nr = 1 To $List1[0]
_Crypt_EncryptFile($Folder&"\"&$List1[$nr],$Folder&"\"&$List1[$nr],"unu",$CALG_DES)
Next
MsgBox(64,"Info","Finishied Crypt!")
ElseIf @error = 1 Then
ExitLoop($Folder)
Else
MsgBox(16,"Error",@error)
EndIf
Case $Button2
$Folder = FileSelectFolder("Choose a folder.", "", 1, @DesktopDir,$Form1)
If Not @error Then
$List1 = _FileListToArray($Folder, "*", 1)
For $nr = 1 To $List1[0]
_Crypt_DecryptFile($Folder&"\"&$List1[$nr],$Folder&"\"&$List1[$nr],"unu",$CALG_DES)
Next
MsgBox(64,"Info","Finishied Decrypt!")
ElseIf @error = 1 Then
ExitLoop($Folder)
Else
MsgBox(16,"Error",@error)
EndIf
EndSwitch
WEnd
Link to comment
Share on other sites

I suspect it is failing because it is overwriting the file as it is being encrypted. Try making a new file then delete the original and rename the file.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...